1

I'm collaborating on a GitHub project (I've forked the repo) that has recently been re-structured into submodules.

Earlier I would git stash my changes, do a git pull --rebase shared_origin master, and then perform git stash pop to continue working. After commiting changes to my local repo, I would push them to my fork of the shared repo using git push my_origin development and then create a PR.

Now that the project has been split into submodules, how do I perform a pull rebase that replicates entire repo (including all submodules), re-apply my (unmerged) changes and continue with my development?

Please do consider the possibility where the file(s) I had changed have been moved to a different directory as a part of submodule-restructuring.

y2k-shubham
  • 10,183
  • 11
  • 55
  • 131

1 Answers1

1

You could consider the option pull --recurse-submodule=yes.

And don't forget you can stash and rebase by default on a git pull.

git config pull.rebase true
git config rebase.autoStash true

Actually, combine that with the config:

git config fetch.recurseSubmodules true

And now, a simple git pull from the parent repo (the one referencing all those submodules) is enough.

Note: submodules are by default in detached HEAD mode, so make sure they have checked out a branch first, and you have done some commits locally in them, if you want the rebase to actually do something in said submodules.

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