assuming that I have a git project that has been changed locally and remotely, so it is obsolete.
If I want to upgrade to the latest remote code without destroying my local work. Git can do it automatically using:
git pull --rebase --autostash
Unfortunately it only works for root module, for git submodule. I have tried the following options:
git submodule foreach git fetch
git submodule update --init --recursive
# git report error:
# Cannot rebase: Your index contains uncommitted changes.
# Please commit or stash them
git submodule foreach git fetch
git submodule update --init --recursive --autostash
# git report syntax error
git submodule foreach git fetch
git submodule update --init --recursive --force
# git destroy local changes
What is the correct way to make submodule to behave similarly to root module?