I used to do what the answer above (https://mcmap.net/q/527911/-stash-everything-in-git-including-all-submodules) said, but it is not ideal really.
The reason it is not ideal is that if you don't have local changes in one of the submodules then git stash
does nothing on that submodule, and when you do git stash pop
you may have different stash queues that don't line up on multiple submodules.
There are workarounds, but I take a different approach:
What I have started doing, which is also not ideal (but might be more ideal) is:
git diff --submodule=diff > temp.patch
git apply -R temp.patch
And then to get back to my old state, I just go:
git apply temp.patch
And I also have *.patch
in my list of files for git to ignore.
git submodule foreach "(git checkout master; git pull)&"
? This command is used for pull for each submodule. Why do they add ampersand at the end and you don't do the same thing? – Esma