Git aliases

By: Priya Philip 1 year ago

The term 'alias' is synonymous with a shortcut. Alias creation is a common pattern found in other popular utilities like `bash` shell. Aliases are used to create shorter commands that map to longer commands. Aliases enable more efficient workflows by requiring fewer keystrokes to execute a command. 

A Brief Example

consider the git checkout command. The checkout command is a frequently used git command, which adds up in cumulative keystrokes over time. An alias can be created that maps git co to git checkout, which saves precious human fingertip power by allowing the shorter keystroke form: git coto be typed instead.


Aliases are created by using the git config command and the Git configuration files. As with other configuration values, aliases can be created in a local or global scope. The appropriate way to add git aliases is in your global .gitconfig file either by editing ~/.gitconfig or by using thegit config --global alias.<alias> <git-command> command.

How do I create Git Aliases?

Method: 1

Create alias using git config --global alias.<alias> <git-command> command.

git config --global alias.c commit

This command will edit the our ~/.gitconfig file. Let's check it by using the following command.

git config --list

The --list or -l command list all variables set in config file, along with their values. We get our alias list also from this:

c = commit

Method: 2

~/.gitconfig file can be manually edited and saved to create aliases.  .

Let’s open theconfig file. You can use any editor that  you want. You can see the alias section something like this:

    c = commit

Let's add the other aliases manually.Under the existing alias for commit, let’s add this:

br = branch
co = checkout
st = status

Save the file and check it is configured or not.

How do i use git aliases?

For commit we created an alias 'c'. Let's see how to write the command  git commit -m "some change  using alias.

git c -m "some changes"


We can save our time by adding aliases but if you add too many at once it can be tough to remember.


Let us talk!

We take the vision which comes from dreams and apply the magic of science and mathematics, adding the heritage of our profession and our knowledge to create a design.