如何在一行中创建包含多个命令的自定义脚本



我想用git扩展创建一个脚本,在一行中使用多个git命令。

以下是我想执行的命令序列:

fetch --all --prune & checkout -f -B master & reset --hard v2.10.0 & submodule foreach git fetch --all --prune & submodule update --init --recursive & submodule foreach git checkout -f -B master

如何将参数彼此分离以使此脚本正常工作?目前我得到以下错误:

error: unknown switch `B'
usage: git fetch [<options>] [<repository> [<refspec>...]]

Greetz

一次执行多个命令的一种方法是:

sh -c "foo && bar && baz"
# check the docs for cmd.exe or powershell if you need to use one of these
# shells instead of 'sh'

尝试设置:

  • 命令:sh
  • 参数:-c "git fetch --all --prune && git checkout -f -B ..."

相关内容

最新更新