Let say I’m owner of two remote projects: MainProject and AppsProject.
In local repository I want to have AppsProject in MainProject‘s subdirectory (apps/).
I’ve tried to use subtree merge strategy (ref.: Pro Git Book)
In MainProject‘s directory. I’ve done that:
$ git remote add apps-remote git@bitbucket.com:me/apps.git
$ git checkout -b apps-branch apps-remote/master
$ git checkout master
$ git read-tree --prefix=apps/ -u apps-branch
$ git checkout apps-branch
$ git pull
Actually what I want now is to be able commit local apps/ changes to AppsProject remote repository and anything what is not in apps/ to MainProject remote repository.
How to do that?
To create a submodule:
Now to clone brand new:
Or if you had it cloned somewhere already but before you added the submodule:
Keep in mind that when you make changes to the submodule, you first want to commit the changes in the submodule, and then commit the changes in the main repo so that it picks it up. The submodule is always frozen at the last commit in the main repo.