Git Alias-具有分支名称的git commit [英] Git Alias - git commit with branch name
本文介绍了Git Alias-具有分支名称的git commit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个git别名来提交一条消息,并在提交消息中自动填充分支名称。
输出示例: git commit -m [EX-1234]这是提交消息
I want to have one git alias to commit a message and auto filling the branch name in the commit message.
output example: git commit -m "[EX-1234] This is the commit message"
我正在寻找一种仅在终端中键入的方法: git cm这是提交消息
,它将执行输出示例。
I am looking for a way to only type in the terminal: git cm this is the commit message
and it will execute the output example.
我尝试过的事情
cm = "git commit -m \'[$(current_branch)] ${1}\'"
cm = "!f() { \
git commit -m '[$(current_branch)] $1'; \
}; f"
cm = '!sh -c '\''git commit --m "${1}"'\'' -'
以上示例不起作用
推荐答案
使用 $ @
将所有参数传播到基础命令,例如:
Use $@
to propagate all the arguments to the underlying command, as in:
cm = "!f() { git commit -m "[$(current_branch)] $@"; }; f"
这篇关于Git Alias-具有分支名称的git commit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文