2

I have a parent (git) project with a submodule (git).

However, when I update the submodule in the parent/develop branch, the parent/master branch also contains the updated submodule files...

So while I want to test my parent code with the updated submodule code, the updates submodule code already appears in master ... what a disaster... that could create.

What I want is that if I update the submodule in parent/develop branch and switch to parent/master, I still see the submodule files before the update. Only after merging develop into master, the updated submodule files should appear in master.

If I look at this post: https://stackoverflow.com/a/17927655/2940885, it looks like the conclusion is that the files of the submodules are untracked and therefore appearing in any branch I checkout.

Any clue on this?

1
  • It's been 3 years. Have you found any better solutions in the meantime? I just ran into this problem and it's making me reconsider using submodules.
    – KobeJohn
    Commented Apr 26, 2016 at 6:14

1 Answer 1

3

See http://git-scm.com/book/en/Git-Tools-Submodules

Switching branches with submodules in them can also be tricky. If you create a new branch, add a submodule there, and then switch back to a branch without that submodule, you still have the submodule directory as an untracked directory: ... You have to either move it out of the way or remove it, in which case you have to clone it again when you switch back—and you may lose local changes or branches that you didn’t push up.

=> So, suppose that is just the way it is..

Not the answer you're looking for? Browse other questions tagged or ask your own question.