我想要一个 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}"'\'' -'
上面的例子不起作用
最佳答案
使用 $@
将所有参数传播到底层命令,如下所示:
cm = "!f() { git commit -m "[$(current_branch)] $@"; }; f"
关于bash - Git Alias - 带有分支名称的 git commit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56977704/