I have sup
别名为submodule foreach 'git co master; git up'
(co
& up
是别名checkout
& pull --rebase
, 分别。)。
如何添加条件,以便如果子模块名称是Libraries/JSONKit
,它检查名为的分支experimental
, 代替master
?
脚本密码为git submodule
运行时其工作目录设置为给定子模块的顶部...因此您可以简单地查看pwd
查看您是否在特定的子模块中。但是,如果您花一些时间阅读git submodule
文档,事实证明更加容易:
foreach
Evaluates an arbitrary shell command in each checked out submodule. The
command has access to the variables $name, $path, $sha1
and $toplevel: $name is the name of the relevant submodule section in
.gitmodules, $path is the name of the submodule directory
relative to the superproject, $sha1 is the commit as recorded in the superproject,
and $toplevel is the absolute path to the top-level of the superproject.
所以你可以这样做:
git submodule foreach '[ "$path" = "Libraries/JSONKit" ] \
&& branch=experimental \
|| branch=master; git co $branch'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)