1

i faced an issue while working on git branches. In the master branch, i have a submodule with tag v2.0 included. I branched out on to a new branch say fix, and made some changes to its artefacts and also updated the submodule to v3.0 via "git checkout v3.0". This i did a commit. Now i switched back to master, with "git checkout master". It displays a message "M submodule" indicating that the submodule configuration is changed and shows a new change. The submodule had changed to v3.0 in the master branch also on its own.

Why does this happen. Why cant i switch between branches without automatic altering of submodule versions?

3
  • Are you sure that you committed the new version of the submodule? Commented Apr 2, 2012 at 15:26
  • the submodule is updated and commited, but externally. it is not changed from within the super-project. I just checked-out a new tag of the sub-module in the new branch, committed it and switched back to master when i see this. Commented Apr 2, 2012 at 15:44
  • What does git status output before switching branches? Does it display any modification to the submodule? (also try git status -s) Commented Apr 2, 2012 at 15:45

1 Answer 1

3

The fix branch has submodule v3.0; the master branch has submodule v2.0. After switching back to the master branch the submodule stays as v3.0 and thus 'git status' shows a submodule change. When you switch branches you need to perform a 'git submodule update' - that will bring the submodule back to v2.0 (the version for master).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.