Git Alias - git commit with branch name

2019-07-23 18:54发布

问题:

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"


标签: bash git alias