git pull --rebase使用子模块foreach失败但在其自己的目录上成功

时间:2014-07-17 19:50:33

标签: git git-submodules

[在底部更新]

这在过去的十五分钟里发生了两次。当我从parentmodule发出以下命令时

git submodule foreach git pull --rebase

它打印有关更新某些子模块的消息,并且'是最新的。'关于其他一些人,直到停在一个以下:

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.

我不记得在foo.bar中做了任何更改。事实上,我已经在此之前发布了git submodule foreach git status,它已经报告了最新情况。所以我试着看看有什么不对,似乎没有错:

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

那么为什么它会因子模块foreach而失败?

更新 似乎git submodule不应该归咎于此。我试过了

git submodule  -q foreach 'echo "cd $name;  pwd; git pull --rebase; cd .."' | bash

那也失败了。然后我在从Windows命令提示符启动的新cygwin bash中尝试了原始命令,该命令没有执行我的~/.bash_profile等等。它成功了。所以还有其他因素导致了这一点。

2 个答案:

答案 0 :(得分:1)

Git子模块如此破碎。我不确定他们上次使用它后是否解决了这个问题。但是没有好的方法来更新子模块分支,因为你的git头文件(我认为它的名称)存储当前提交它是一种硬编码非常难以更新的方式。我发现自己真的不得不从repo中删除整个子模块,然后将其放回每次更新。 (在我的链接中更好地解释)

确保正确分配.git/configure,并在更新子模块时运行这两个命令。

git submodule init
git submodule update

我仍然发现使用它时非常痛苦。


有两个值得关注的帖子。

Overview of Gitsubmodules

Why Git Pull Doesn't Work

答案 1 :(得分:1)

显然这是由我的~/.git-prompt.sh引起的,它也是非交互式shell的来源。

source ~/.git-prompt.sh; PS1=....

中保护[[ $- == *i* ]]~/.bashrc后问题消失了
相关问题