How to create and remove aliases in GIT


I would like to know the commands to create an alias, I know that I can shorten my commands and make it faster and more productive, but I still do not know how to do this. Does anyone know the create and remove commands?

asked by anonymous 23.02.2014 / 16:00

2 answers


You can add them to your ~/.gitconfig :

    st = status
    ci = commit -v

Or you can use the command alias of git config:

$ git config --global status 
$ git config --global 'commit -v'

More information can be found at documentation (English) .

Response Credits for @Diego Dias in SOEN in this answer .

23.02.2014 / 16:05

I'll assume you work in Linux or OSX environment.

These aliases you place in your ~/.bashrc (in the case of Linux) file or in the ~/.bash_profile file (in the case of OSX). Edit them in Vim (do not need sudo ) and put some aliases like:

alias gs='git status;'
alias gc='git commit $1;'
alias gca='git commit -am $1;'
alias gcap='git commit -am $1; git push;'

(only one detail: use = and not = with spaces around, as this is a comparison operator)

Anyway, these are some of the commands I set up for my environment. You can create the commands you want for your case.

Ah! Do not forget to give a source ~/.bashtrc (or source ~/.bash_profile in the case of OSX) to load the commands after you enter them. However, whenever you restart the system, the commands will already be available.

23.02.2014 / 16:09