Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make this git command alias?

Tags:

git

alias

bash

I want to make a alias, like this below

gc this is a test message convert to git commit -m "this is a test message".

How can I do this? I want that in my bashrc.

like image 503
user392412 Avatar asked Nov 04 '11 07:11

user392412


2 Answers

I have these alias in my .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'

I normally commit with gm "msg"

like image 178
fuzzyalej Avatar answered Sep 29 '22 06:09

fuzzyalej


bash alias definitions don't take parameters.

Try using a bash function in your .bashrc:

function gc () { 
    git commit -m "$*" 
}
like image 25
John Weldon Avatar answered Sep 29 '22 06:09

John Weldon