我试图为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美元,这对蚂蚁的建议没有帮助吗?
答案 0 :(得分:1)
发现错误,输入$ 1应该在引号之外:
[alias]
subco = "!f() { git submodule foreach 'git checkout '$1' || true'; }; f"