I have written about the git subtree module before.
It has been improved, to allow defining your subtrees and imported projects in a config file, in order to update them without having to specify the repo url and branch every time you push to or pull from an imported project.
So, first you need to setup the subtree :
$git subtree add --prefix=other_project \
git://github.com/your_tree/your_project.git master
It imports the master branch of a git repository located in git://github.com/your_tree/your_project.git into the folder other_project of your git repo.
A file .gittrees in the root folder of your git repo is created :
[subtree "other_project"]
url = git://github.com/your_tree/your_project.git
path = other_project
branch = master
With the subtree being defined in .gittrees, you can make changes to this imported project and you want to push them back to the original project, you can use this :
$git subtree push --prefix=other_project
Or if you want to update the imported project with changes from the original project, you can use this :
$git subtree pull --prefix=other_project
You can also push all changes in imported projects to the original projects, with
$git subtree push-all
It will push all changes to projects that are defined in the .gittrees config file.
Pull changes from all defined subprojects is done with :
$git subtree pull-all
BTW : All subtree commands must be run in the root folder of your git repo.
BTW2: the subtree module is not part of the core git package. So if you want to use it, you will have to install the module first.
Clone the subtree project :
$git clone https://github.com/helmo/git-subtree
In the git-subtree directory, run as root :
#./install.sh
This will copy the git subtree module to the git script folder. You can now use the git subtree module.
