I have a git repo with a dev and a master branch. Now I am trying to use a different revision of a submodule in each branch. So for example I do this:
git checkout master
cd submodule
git checkout v1.0
cd ..
git commit -a -m "now using submodule v1.0"
git checkout dev
cd submodule
git checkout v2.0
cd ..
git commit -a -m "let's try submodule v2.0"
Now after that I checkout the master branch and it seems the submodule in the master branch is also pointing to the v2.0 commit instead of v1.0.
I’ve read quite a lot about git submodules, but it still seems a bit abstract to me. Could anybody explain how to use a submodule properly in this particular case? (git version 1.7.3.1)
Thanks!
Just changing branches in the super-project isn’t going to change the contents in the submodule; the branch change will only change the super-project’s commit reference for its submodule. You need to do:
after checking out a branch in the super-project. The ‘update’ will change the submodule to reference the proper commit. Here is an example: