Git – submodules

We’re developing project which has 3 different apps with its own repositories. So we have repos of main app, node server, admin app. All of these we want to deploy to production server, so our project repo will have deployment scripts, puppet manifests and these 3 repos included. We achieve these goal by using git’s submodules:

// repo central server - RCS
mkdir project.git
cd project.git
git --bare init

// on deployment machine
git clone RCS:project.git
cd project
git submodule add RCS:main_app.git main_app
git submodule add RCS:node_server.git node_server
git submodule add RCS:admin_app.git admin_app
git commit -am 'Initial project commit'
git push origin master

Now You can create deployment scripts and also include them in project repository.

To clone this repository on another machine we use command:

git clone --recursive RCS:project.git

To pull changes from all submodules just type:

git submodule foreach git pull
Advertisements