使用"git submodule foreach"您可以跳过子模块列表吗? [英] using "git submodule foreach" can you skip a list of submodules?
问题描述
让我说我有10个子模块:
lets say I have 10 submoules:
module/1
module/2
module/3
module/4
module/5
module/6
module/7
module/8
module/9
module/10
其中 module/
是顶级存储库.
我想为每个"git status"做 git子模块
,但是我不想为子模块4、6和7做它.
I want to do git submodule foreach 'git status'
, but I don't want to do it for submodules 4, 6 and 7.
有没有办法做到这一点,像:
Is there a way to do that, somthing like :
git子模块foreach --exclude ="4 6 7"'git status'
我尝试使用
git submodule foreach '
if [[ $list_of_ignores =~ *"$displayname"* ]] ; then echo ignore; fi
'
更新-删除了偶然在其中的-exclude ="4 6 7"
update - removed --exclude="4 6 7"
that was accidently in there
但是我收到错误消息,说 eval [[:未找到
-我假设这是因为它使用的是/bin/sh而不是/bin/bash?-不确定...
But I get errors saying eval [[: not found
- I am assuming this is because it is using /bin/sh instead of /bin/bash? - not sure...
推荐答案
正如文档所述,foreach执行shell命令,
As the docs say, foreach executes shell commands,
foreach [--recursive] <command>
Evaluates an arbitrary shell command in each checked out submodule. The
command has access to the variables $name, $sm_path, $displaypath, $sha1
and $toplevel
因此使用外壳程序:
git submodule foreach 'case $name in 4|6|7) ;; *) git status ;; esac'
我尝试了这个.有用.我尝试过按您说的尝试进行的操作.它不会给出您说的错误,Git拒绝它是一个错误的选择.请停止在您的问题中伪造证据.
I tried this. It works. I tried c&p'ing what you said you tried. It doesn't give the error you say, Git rejects it for a bad option. Please stop faking evidence in your questions.
这篇关于使用"git submodule foreach"您可以跳过子模块列表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!