cod*_*der 3 linux git foreach git-submodules
假设我有 10 个子模块:
module/1
module/2
module/3
module/4
module/5
module/6
module/7
module/8
module/9
module/10
Run Code Online (Sandbox Code Playgroud)
module/顶级回购在哪里。
我想做git submodule foreach 'git status',但我不想为子模块 4、6 和 7 做。
有没有办法做到这一点,比如:
git submodule foreach --exclude="4 6 7" 'git status'
我尝试在命令块内使用
git submodule foreach '
if [[ $list_of_ignores =~ *"$displayname"* ]] ; then echo ignore; fi
'
Run Code Online (Sandbox Code Playgroud)
更新- 删除--exclude="4 6 7"了意外在那里
但是我收到错误说eval [[: not found- 我假设这是因为它使用 /bin/sh 而不是 /bin/bash?- 没有把握...
正如文档所说,foreach 执行 shell 命令,
Run Code Online (Sandbox Code Playgroud)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'
Run Code Online (Sandbox Code Playgroud)
我试过这个。有用。我试过 c&p'ing 你说你试过的。它没有给出你说的错误,Git 拒绝它作为一个错误的选择。请停止在您的问题中伪造证据。