Git 如何将bash脚本的所有命令行参数作为一个参数传递给另一个程序?

Git 如何将bash脚本的所有命令行参数作为一个参数传递给另一个程序?,git,bash,Git,Bash,我希望编写一个简单的git脚本,它将运行以下几行: cd <the name of my git repo> git add * git add -u git commit -m "<my comment in the form of a string>" git push origin master 如何更改脚本以使其与多词提交注释一起工作?以下是一些可以帮助您的git别名示例。我也在做类似的事情 例如: rem = !sh -c 'test "$#" = 1 &a

我希望编写一个简单的git脚本,它将运行以下几行:

cd <the name of my git repo>
git add *
git add -u
git commit -m "<my comment in the form of a string>"
git push origin master

如何更改脚本以使其与多词提交注释一起工作?

以下是一些可以帮助您的git别名示例。我也在做类似的事情

例如:

rem = !sh -c 'test "$#" = 1 && git h && git checkout master && git pull && git checkout \"$1\" && git rebase master && git checkout master && git merge \"$1\" && echo Done and ready to do: git pom && exit 0 || echo \"usage: git rem \" >&2 && exit 1' -

# git rem
usage: git rem ...

# git rem my_branch
...

它使用一个参数,并且所有命令都与&&连接,如果链中的任何命令(例如merge)失败,则会立即停止,错误代码为1。祝别名好运。

这里最快的答案是,在脚本中,提交行应该是


git commit-m“$*”
Bash执行字符串插值。如果替换该行,脚本应该可以

git commit -m $*
git commit -m "$*"


应该为您这样做。

尽管这不是我想要的,但我想这对我的其他需求也有帮助:DMy的意图是您可以使用类似的方法。:-)因为这是最早的回复告诉我这样做:请注意:多行提交注释(在“主题行”后面有一行空行)通常很有用。您也可以使用脚本执行此操作,只需在关闭
”之前按enter键即可。谢谢!我将使用它!
git commit -m $*
git commit -m "$*"
git commit -m "$*"