Alyssa Holland
Alyssa Holland's Blog

Alyssa Holland's Blog

How to Configure Git Aliases

How to Configure Git Aliases

Alyssa Holland
ยทSep 18, 2020ยท

2 min read

Subscribe to my newsletter and never miss my upcoming articles

A Note on the Series:

Fast Fridays ๐ŸŽ is a series where you will find fast, short and sweet tips/hacks that you may or may not be aware of. I will try to provide these (fairly) regularly on Fridays.


An alias is simply a shortcut that can reference a longer command. When an alias is configured, git will substitute the alias with the command that it is mapped to. Setting up aliases for common git commands can speed up your workflow and efficiency as you will spend less time typing or trying to remember full commands.


Aliases can be set up in two different ways:

  1. Using the git config command.
  2. Directly editing the git config files in your $HOME/.gitconfig file.

I would recommend going with option #1. I find this to be the fastest way to set things up so that will be the method I discuss. However, feel free to do whatever works best for you.

Let's say you wanted to set up aliases for three common git commands: branch, checkout, and status. To configure those aliases you would run the following in your terminal:

git config --global branch
git config --global checkout
git config --global status

If you view the .gitconfig file in your home directory you should now see this:

      br = branch
      co = checkout  
      st = status

If you want to add a git alias for commands that have spaces, wrap the command in double ("") or single ('') quotes.

git config --global alias.undo "reset --hard"

The next time you want to run any of those commands, you can now utilize the aliases you just set up! For example, git br will now execute the same operation as git branch and git undo will now execute git reset --hard.

El Fin ๐Ÿ‘‹๐Ÿฝ

With a few simple short steps, you can quickly improve your git workflow. The examples I provided are some of the aliases I use but there tons more options that you can easily configure. Thanks for reading and happy coding!


Share this