Py学习  »  Git

git子模块foreach不作为别名

amsmota • 4 年前 • 771 次点击  

我以前用命令

git submodule foreach git status

或者命令可能失败

git submodule foreach "git checkout develop || true"

所以现在我为第一个表单创建了一个别名,它可以正常工作

git config --global alias.all '!f(){ git submodule foreach "git $@"; }; f'

然后我试着在第二种状态下也这样做,但根本不起作用

git config --global alias.all '!f(){ git submodule foreach "git $@ || true"; }; f'

注意,我仍然可以使用它第一个像

git all "checkout develop || true"

但在使用别名时,这看起来是不必要的输入。

在上面的例子中,它使用“git all”给出的错误是 错误:pathspec“develop | | true”与git已知的任何文件都不匹配

在“子模块”中,它输出一个错误,但会继续到下一个子模块。

有没有关于如何修复第二个版本的指针?

干杯。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/51225
 
771 次点击  
文章 [ 1 ]  |  最新文章 4 年前
phd
Reply   •   1 楼
phd    4 年前

对我有效(几乎):

$ git config alias.all

$ git config alias.all '!f(){ git submodule foreach "git $@ || true"; }; f'

$ git config alias.all
!f(){ git submodule foreach "git $@ || true"; }; f

$ git all checkout master
Entering 'genxml'
/usr/lib/git-core/git-submodule: 342: /usr/lib/git-core/git-submodule: git checkout: not found
Stopping at 'genxml'; script returned non-zero status.

嗯,奇怪的是,我希望它的工作方式和下面一样:

$ git all "checkout master"
Entering 'genxml'
error: pathspec 'master' did not match any file(s) known to git.
Entering 'third-party/c14n2'
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Entering 'third-party/cmclib'
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Entering 'third-party/eplant'
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Entering 'third-party/pycryptoserver'
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Entering 'third-party/ufod'
warning: unable to rmdir ufod/xsd: Directory not empty
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

至少这是意料之中的。