Short answer:
cd ProjectFooBarCommoneSubmodule git checkout master <Do your editing> git commit --all -m "Lots of fixes" git push submodule_origin master cd .. git add ProjectFooBarCommoneSubmodule git commit -m "Bumped up the revision of ProjectFooBarCommoneSubmodule" git push origin master
The longer:
Submodules
Git is a dependency mechanism where the main project (say, A) defines the specified revision in the subproject (say, B) that will be used to build the project A. In order for the tool to be useful, the behavior must be predictable from the point of view of A: s . Dependencies cannot change unless someone decides to include the change in project A. All sorts of unpleasant things can happen: did the changes to the project B: s automatically import, of which the compilation errors are probably the best, since A would immediately notice the failures. This is why the B: s head is off.
State B is stored in (check git submodule status ), and the change change must be made and committed to A in order for it to have any effect. This is what happens in the above example, A changes the revision number stored in the repo and dials the version to the latest. This process will need to be repeated in another main repo, so the automatic "use of the master switch" AFAIK.
BTW. Git is the head of a book on submodules and my github account . Commits do not make sense and contain garbage, but tuning should be fine. Please check this to follow.
Both ProjectFoo and ProjectBar share code in a common submodule.
ProjectFooBarCommoneSubmodule: master 6850e4e4c1fac49de398
In ProjectFoo:
git submodule status
-6850e4e4c1fac49de39890703f21486ca04b87a0 general
In ProjectBar:
git submodule status
-6850e4e4c1fac49de39890703f21486ca04b87a0 general
So both point to the same revision, right? The trick here is to see that ProjectFoo and ProjectBar point to the version (6850e4e4c1fac49de39890703f21486ca04b87a0) not a branch (master), although they are the same thing. The first is a separate head, and the other is a named branch.
If you want to make some corrections in ProjectFooBarCommoneSubmodule, you can go to a subdirectory, for example. ProjectFoo and select the branch instead of the revision :
git checkout master <Do your coding and pushing here>
Then go up one directory and check the status of the git submodule. He must tell you that you are not synchronized right now. for example
git submodule status
+ e24bd2bf45d52171a63b67ac05cd4be0ac965f60 general (heads / master-1-ge24bd2b)
Now you can do git add to set the link to this particular commit (ge24bd ...), commit, and after that the link to the submodule points to this revision, which is also the wizard for ProjectFooBarCommoneSubmodule.
Now you need to update the link in ProjectBar. Go to ProjectBar / common and do git fetch origin (this is a quick merge forward), do
git checkout master cd .. git add common git commit -m "Bumped up the revision" git push origin master
So, as with any git repository, you don't have to work with a separate head. You can either work with the wizard or create a named branch. Either way, make sure that the upstream stream contains changes to ProjectFooBarCommoneSubmodule, or you break ProjectFoo and ProjectBar if they refer to something that doesn't exist. Hope this explained it better.