如何制作这个git命令别名?

use*_*412 5 git bash alias

我想创建一个别名,如下所示

gc this is a test message转换为git commit -m "this is a test message".

我怎样才能做到这一点?我希望在我的bashrc中.

Joh*_*don 9

bash alias定义不带参数.

尝试在.bashrc中使用bash函数:

function gc () { 
    git commit -m "$*" 
}
Run Code Online (Sandbox Code Playgroud)


fuz*_*lej 9

我的.bashrc中有这些别名:

alias ga='git add'
alias gp='git push'
alias gl='git log'
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gm='git commit -m'
alias gma='git commit -am'
alias gb='git branch'
alias gc='git checkout'
alias gra='git remote add'
alias grr='git remote rm'
alias gpu='git pull'
alias gcl='git clone'
Run Code Online (Sandbox Code Playgroud)

我通常承诺 gm "msg"


kro*_*sey 6

这不是别名,但请尝试

function gc() {
  git commit -m "$*"
}
Run Code Online (Sandbox Code Playgroud)