How to Configure Git Aliases

Welcome to my blog ππ½
I'm a Front-End Developer with a passion for learning!
I write about Programming π©π½βπ» and Productivity Tips β
Search for a command to run...

Welcome to my blog ππ½
I'm a Front-End Developer with a passion for learning!
I write about Programming π©π½βπ» and Productivity Tips β
It's a simple and useful post. Thanks for Sharing Alyssa Holland. Does this work on Windows as well?
Hey Skay! Iβm personally a Mac owner but if you are able to run git commands already on Windows, I would assume that you can configure aliases. I can try and do some research on that though.
In this series, 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.
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. Firefox provides a simple and easy way to be able ...
Although my experience is primarily with front-end development, my current job is affording me the opportunity to do more full-stack work. Naturally, this meant that I needed to explore the different database GUIs available on the market. Here is a l...

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. In this Fast Friday tip, I'll explain how to crea...

Over the past year, Iβve started incorporating a Git GUI into my workflow. I still reach for the terminal about 90% of the time, but Iβve found that a GUI can really shine when it comes to things like viewing diffs, checking stashes, or resolving mer...

Simplifying Branch Management with Git Worktree

With all the AI tools popping up these days, I figured I'd try out some speech-to-text software in an attempt to boost my productivity. I've been hearing a lot about βdeveloping at the speed of thoughtβ, so here's a list of the top speech-to-text sof...

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:
Using the git config command.
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 alias.br branch
git config --global alias.co checkout
git config --global alias.st status
If you view the .gitconfig file in your home directory you should now see this:
[alias]
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.
To remove an alias you can either delete the command from the $HOME/.gitconfig file directly or run:
git config --global --unset alias.<alias-in-file>
For example, if you wanted to remove the alias to check the git status, you could run the following command: git config --global --unset alias.st
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 are tons more options that you can easily configure. Thanks for reading and happy coding!