1

我希望有一个 git 别名来提交消息并在提交消息中自动填充分支名称。输出示例:git commit -m "[EX-1234] This is the commit message"

我正在寻找一种仅在终端中输入的方法:git cm this is the commit message它将执行输出示例。

我尝试过的事情

cm = "git commit -m \'[$(current_branch)] ${1}\'"
cm = "!f() { \
         git commit -m '[$(current_branch)] $1'; \
       }; f"
cm = '!sh -c '\''git commit --m  "${1}"'\'' -'

上面的例子不起作用

4

1 回答 1

2

用于$@将所有参数传播到底层命令,如下所示:

cm = "!f() { git commit -m "[$(current_branch)] $@"; }; f"
于 2019-07-10T19:54:37.617 回答