Git Alias: Config – The Best Git Aliases

An alias in Git is a shortcut that Git translates into a full-text command.

With the aliases you can avoid typing the entire text of each of the Git commands over and over again, that significantly improves the experience of working with Git from the command line.

In this note i will show how to set up the aliases in Git using the git config alias command.

Cool Tip: Show Git config settings! Read more →

Git Config Alias

Use the following syntax to configure an alias in Git:

$ git config --global alias.<SHORTCUT> <COMMAND>

For example, to start using the git p shortcut for the git push command, execute:

$ git config --global alias.p push

The --global option tells Git to store aliases in the user’s global ~/.gitconfig file.

Execute the following commands to configure the most popular Git aliases:

$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status

The Best Git Aliases

Contribution Is Welcomed: If you know other handy Git aliases – please, leave a comment below this post.

Display Git commits as single lines for more pretty output:

$ git config --global alias.ll 'log --pretty=oneline --abbrev-commit'

Show last Git commit:

$ git config --global alias.last 'log -1 HEAD --stat'

Show Git Aliases

To list the Git aliases, execute:

$ git config --get-regexp alias

Cool Tip: Increase VERBOSITY of Git commands! Read more →

Leave a Reply