Update Submodule content per parent branch

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.

How do I solve this?

(Using SourceTree git on Mac).

1 answer

1 accepted

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:

$ git checkout -b rack Switched to a new branch "rack" $ git submodule add git@github.com:schacon/rack.git rack Initialized empty Git repository in /opt/myproj/rack/.git/ ... Receiving objects: 100% (3184/3184), 677.42 KiB | 34 KiB/s, done. Resolving deltas: 100% (1952/1952), done. $ git commit -am 'added rack submodule' [rack cc49a69] added rack submodule 2 files changed, 4 insertions(+), 0 deletions(-) create mode 100644 .gitmodules create mode 160000 rack $ git checkout master Switched to branch "master" $ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # rack/ 

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..

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Agile

How Davin Studer gets Confluence to do everything he wants it to do...except dishes

  @Davin Studer holds many interests, including but not limited to health tech and Star Trek. Read on to discover more about Davin, from his favorite Confluence macros to his favorite lit...

188 views 1 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you