0

[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.

Miserable Variable
  • 28,432
  • 15
  • 72
  • 133

2 Answers2

1

Git submodules are so broken. I'm not sure if they fixed the problem since I last used it. But there is no good way to update a submodule branch because, your git head file (I think that's what its called) stores current commit it a hard coded very hard to update manner. I found myself literally having to delete the entire submodule from the repo and then putting it back for every update. (Better explained in my link)

make sure you .git/configure is correctly assigned and you run these two commands when you update the sub module.

git submodule init
git submodule update

I still found it pretty painful to use just be aware.


There are two posts worth looking at.

Overview of Gitsubmodules

Why Git Pull Doesn't Work

Community
  • 1
  • 1
progrenhard
  • 2,333
  • 2
  • 14
  • 14
1

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

Miserable Variable
  • 28,432
  • 15
  • 72
  • 133