The number of times in my life where the phrase “know your tools” has been relevant is surprising in hindsight. I’ve heard the phrase used in different industries and applied in different ways. However, I think it is as true today as it was the first time I heard it. Having familiarity with your tools makes life easier and, if you’re lucky, might just impress your cats.

Beyond Your IDE

Version control in software development is not new and there have been several tools used over the years to help you manage changes to source code over time. The Git version control system is one of the most ubiquitous today, and it’s likely you or your teams are familiar with it and are using it daily.

It may be that in most cases the integrations provided by your favorite IDE allow you to perform most tasks needed for day-to-day software development with the click of a mouse. Not all projects are created equal though. Not all commands make it into a UI. Becoming more familiar with Git can help you become more efficient and spend less time figuring out the tool and more time on the task at hand.

I became so used to using these Git aliases over the years that when I find myself on a system without them, I’ve first thought something was wrong. That is what prompted this article.

Git Aliases

Git aliases are a feature of the tool that are often overlooked by many developers. In fact, there is just one small page on them in the official documentation. They deserve another mention and the way they work is also a great introduction to customizing Git and your workflow to make things more personalized to your project or development style.

You can add aliases globally, per user, or just in the current repository using git config.

Try it out. In the example below, the command git last will expand to git log -1 HEAD. This will show information about the latest commit.

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

This command is added globally to you in your local git config such as ~/.gitconfig on a Linux system.

Alias Common Commands

Here are some examples of the ones I’ve become so used to that I feel like someone is forcing me to go back to using the CVS version control system when they are missing on a new system.

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

Get Creative

Get creative and customize your environment and workflows to meet the needs of any project. From simple aliases to more advanced squashing and merging. Make your tools work for you, and pick the right tool for the job. Your cats will love you for it.

Bonus

To easily see a commit graph like the image at the top of this post.

git config --global alias.graph 'log --graph --oneline --all'

Happy coding.

Related Post

Leave a Reply