[update at bottom]
This has now happened twice in last fifteen minutes. When I issue the following command from parentmodule
git submodule foreach git pull --rebase
It prints messages about updating some submodules and 'is up to date.' about some other until stopping at one with the following:
Entering 'foo.bar'
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.
Stopping at 'foo.bar'; script returned non-zero status.
I do not remember making any changes in foo.bar. As a matter of fact I had issued git submodule foreach git status
immediately before this where it had reported up to date. So I try to see what is wrong and there seems to be nothing wrong:
$ cd foo.bar/
14 07 17 12:38:03 I063510@OAKN00563024A /c/git/mainbuild/foo.bar (staging)
$ git st
On branch staging
Your branch is up-to-date with 'origin/staging'.
nothing to commit, working directory clean
14 07 17 12:38:08 I063510@OAKN00563024A /c/git/mainbuild/foo.bar (staging)
$ git pull --rebase
remote: Counting objects: 19, done
remote: Finding sources: 100% (10/10)
remote: Total 10 (delta 5), reused 9 (delta 5)
Unpacking objects: 100% (10/10), done.
From ssh://git.wdf.sap.corp:29418/smp/server/dist/com.sap.mobile.platform.server.foo.bar
214e0c9..266b279 master -> origin/master
Current branch staging is up to date.
So why did it fail with submodule foreach?
UPDATE
It seems git submodule
is not to be blamed here. I tried
git submodule -q foreach 'echo "cd $name; pwd; git pull --rebase; cd .."' | bash
and that failed too. Then I tried the original command in a new cygwin bash
started from windows command prompt that did not execute my ~/.bash_profile
etc. And it succeeded. So there is something else that is causing this.
Apparently this was caused by my ~/.git-prompt.sh
which was getting sourced for non-interactive shells also.
The problem disappeared after I protected source ~/.git-prompt.sh; PS1=....
inside [[ $- == *i* ]]
in my ~/.bashrc