签出每个git子模块中的一个特定分支

签出每个git子模块中的一个特定分支,git,git-submodules,Git,Git Submodules,我正在尝试为git编写一个别名,它将接受分支名称,并在每个子模块中递归地签出它。预计某些子模块可能没有此分支,因此将跳过它们 我尝试了这个解决方案: [alias] subco = "!f() { git submodule foreach 'git checkout $1 || true'; }; f" 位它给我错误,$1-输入不正确 Entering 'Services/Payment' error: pathspec 'git' did not match any file(s) kno

我正在尝试为git编写一个别名,它将接受分支名称,并在每个子模块中递归地签出它。预计某些子模块可能没有此分支,因此将跳过它们

我尝试了这个解决方案:

[alias]
subco = "!f() { git submodule foreach 'git checkout $1 || true'; }; f"
位它给我错误,$1-输入不正确

Entering 'Services/Payment'
error: pathspec 'git' did not match any file(s) known to git.
error: pathspec 'checkout' did not match any file(s) known to git.
error: pathspec '$1' did not match any file(s) known to git.
error: pathspec '||' did not match any file(s) known to git.
error: pathspec 'true' did not match any file(s) known to git.

我试图在引号中加上$1,但没有用,ant建议?

发现错误,输入$1应在引号之外:

[alias]
subco = "!f() { git submodule foreach 'git checkout '$1' || true'; }; f"