How to create aliases to git commands

You can set aliases for common git commands using the following command:

git config --global alias.poule pull

In this instance, we create an alias for git pull so git poule does a pull. Since we have used the --global flag, this applies to all of your projects.

Here is a more useful alias. It shows a short, colorful git log including the history graph. Call it with the git lg command.

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

You can find a list of your aliases and other config options in the .gitconfig file in your home directory.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax