How to Utilize Git Aliases

Recently I had the opportunity to volunteer my time as a React developer for a non-profit start up. Upon working with the tech lead, I quickly realized that I could learn a lot from this person, from in depth technical knowledge, to simple shortcuts that would make my life as a developer easier. Git Aliases are certainly one of those shortcuts that every one should know to make their production go just that much smoother

What Is and Alias?

In Git, an Alias is exactly what it sounds like. It is a nickname or alias you create for common git commands. Put simply, it is the difference between typing out an entire Git command, and entering a shortcut you created to execute the same process. This can be easily understood if we take a look at some examples.

Creating My Own Git Alias

If you are familiar with Git, you are most likely familiar with the common command git status. This command is short, only two words, but imagine having to type it out over thirty times in the span of a day. This takes up a lot of time doing something repetitive, going against a programmers natural D.R.Y. (don’t repeat yourself!) instincts.

In order to shorten this process, we can write an alias for the git status command!

By using git config, we can configure our git to run git status whenever we enter the command gs. As you can see in the image, we simply enter the word alias followed by a period, and after that we enter the shortcut letters we wish to use. As the final argument, we enter the git command we are replacing with our new shortcut, so in this example it is gs in place of git status.

Now we can type in gs whenever we need to see the git status, and expect the same output as if we had entered the command in long hand.

Some More Uses

Of course I am sure you are already thinking of your own uses for aliases. You can set aliases for checkouts, branches, commits, or anything else you can imagine with Git that you may be doing multiple times in one programming sitting.

A common use of aliases is to create commands that do not currently exist by combining a flag with a command or multiple commands. One common and useful alias to consider creating is to view your last commit. You can do this by simply entering the following:

Then if we enter git last we receive the last commit:

Try It Out!

These are just two simple examples, but the possibilities with Aliases are extensive. They can make your programming experience quicker, more efficient, and easier. I recommend trying out these commands, and then trying to create some of your own Aliases for git commands you use often.


I ‘m a Web Developer and a Flatiron coding bootcamp alumni. I currently work in the financial tech industry as a Front End Engineer