1

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.

e.g.

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

I made changes to quite a few files under /testing/* and /testing/lib/xyz/*

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 /testing/lib/xyz/* 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.

Community
  • 1
  • 1
slayedbylucifer
  • 22,878
  • 16
  • 94
  • 123
  • I do not quite get what problem you are facing. A sub-module is just its own git repo. Thus, you have changes in two separate repos and necessarily need to create new branches in both repos, independently. As the main repo is referencing the sub-module, making the changes first in the sub-module is advisable, but not necessary. – Martin Nyolt Sep 01 '16 at 07:56
  • you just need to commit changes in submodule (probably to new brach in that repo) and then it can be referenced from main repo in .gitsubmodule – V-master Sep 01 '16 at 09:56

1 Answers1

1

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250