How to Create Git Aliases that Supercharge your Workflow

Git has a built-in alias system that allows you to create custom commands, similar to npm run scripts or a simple alternative to a Makefile.

Why Use Git Aliases?

A Git alias can:

Example: Deploying a GitHub Pages Site

Let’s say we frequently update a GitHub Pages site stored in a /www directory. Normally, we would run:

git push origin main
git subtree push --prefix www origin gh-pages  

Instead, we can create a custom Git alias:

git config alias.deploy '!git push origin main && git subtree push --prefix www origin gh-pages'  

Now, we can deploy everything with a single command:

git deploy  

How Git Aliases Work

Conclusion

Git aliases are a simple way to automate repetitive tasks. Whether you use them for deployments, logs, or rebases, they can speed up your workflow and keep commands consistent.

A Note About AI

I used AI to help write this article. It’s a tool I use in a lot of my work.

Originally I was working with an AI chat bot to help me deploy a site from the www folder on Github. From that synthetic conversation I learned about git aliases for the first time. After I finished the original project I wanted to share what I had learned about aliases. I usually write for my future self, and this article is no different. I gave AI a few instructions for what I wanted the article to contain and I let it ghost write most of it for me.

When the article was finished I used AI again to re-write the headline based on the tips I recently read on psychotactics.com.

Over time I’ll update the text and it will become more and more my own and the lines between AI and my own writing will become blurred.

Written by Joel Dare with the help of an AI on March 17, 2025.


Joel's Newsletter

Get a monthly digest of what I'm up to.

Subscribe by Email