Сценарий passwd для 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'