slayedbylucifer slayedbylucifer - 1 year ago 115
Git Question

How to move uncommitted changes in a submodule to a new branch

My question is partially duplicate of Moving uncommitted changes to a new branch

However, The trick is, I made changes to few files which belong to a sub-module.


My Primary repo: /testing
Sub-module is at: /testing/lib/xyz

I made changes to quite a few files under

Now I can do a
git checkout -b new_branch
and get my uncommitted changes to a new branch. But this will not get the changes under
to the new branch because this path belongs to a sub-module.

Question: How do I move my uncommitted changes including changes to submodule to a new branch.

The reason being, In my haste, I made quite a few changes to a lot of files in my master branch to fix something. Now the fix is working, however, I do not want to merge these changes to master and I do not want to loose these changes as well. So I thought of moving these changes to a new branch and then continue working on the new branch. But then I faced this sub-module issue.

Answer Source

A sub module is a git repo: you can create a branch there to reference your new changes, just as explained in "Moving uncommitted changes to a new branch".

Then reset its content to its own master branch.

I would advise to push that branch to the submodule remote origin repo, in order to avoid keeping those changes purely local.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download