Git Alias - git commit with branch name

拜拜、爱过 提交于 2020-01-05 03:46:29

问题


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"

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.

Things I have tried

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

The above examples dont work


回答1:


Use $@ to propagate all the arguments to the underlying command, as in:

cm = "!f() { git commit -m "[$(current_branch)] $@"; }; f"


来源:https://stackoverflow.com/questions/56977704/git-alias-git-commit-with-branch-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!