Typing Git Commands: A Small Task That’s Surprisingly Annoying
Think about it: on average, you type Git commands about 40-60 times a day. With familiar commands like git status, git add ., or git commit -m "...", you are repeating a tedious manual process.
The problem isn’t just tired hands. In reality, default Git commands are often long and prone to typos. I once spent nearly a minute struggling to type git log --graph --oneline --all --decorate just to check branches. One typo in “decorate” and you have to start over. That feeling is incredibly frustrating when you’re trying to stay in deep focus.
This delay creates “friction” in your workflow. Git Alias was born to eliminate this nuisance. It allows you to redefine any command in the shortest and most memorable way possible.
Two Ways to Set Up Git Aliases Fast
You can create Git shortcuts in two ways. Choose the method that fits whether you prefer using the terminal or editing a configuration file.
Method 1: Typing Directly in the Terminal
This is the fastest way to add a few simple aliases. Just run the command using this syntax:
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
From now on, instead of typing 10 characters for git status, you only need 2: git st. That’s an 80% reduction in keystrokes!
Method 2: Editing the .gitconfig File
I usually prefer this method because it helps manage the list of aliases more centrally. Open the global configuration file with the command:
git config --global --edit
This file is usually located at ~/.gitconfig on macOS/Linux or in the User directory on Windows. Just find the [alias] section and add your configuration lines.
A Collection of Basic to Advanced Aliases for Developers
Don’t just shorten single commands. The true power of Aliases lies in wrapping complex parameters into a single keyword.
1. The “Essential” Command Group
This is the skeleton I always set up first on any new machine:
[alias]
st = status
co = checkout
br = branch
ci = commit
df = diff
last = log -1 HEAD
The git last command is extremely useful when you want a quick peek at the most recent commit without flooding your screen with a long log list.
2. Turning Git Log into a Visual Chart
The original git log command is hard to read, especially when a project has many overlapping branches. Try using this alias to turn it into a colorful chart:
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
With just git lg, your entire commit history appears clearly. Hash codes are in red, branch names in yellow, and commit times in green. You’ll never want to go back to the old black-and-white logs again.
3. Running Shell Scripts Directly (Pro Level)
Sometimes you need to perform a sequence of actions that pure Git cannot do. Use the exclamation mark ! to call shell commands.
For example, to clean up “junk” branches that have been merged into main, use git cleanup:
[alias]
cleanup = "!git branch --merged | grep -v '\*' | xargs -n 1 git branch -d"
Or use the git amend command to quickly fix the last commit’s content without opening an editor:
[alias]
amend = commit --amend --no-edit
Tips for Managing and Sharing Aliases within a Team
When the list of shortcuts gets too long, it’s hard to remember them all. Create an alias to list… itself:
git config --global alias.alias "config --get-regexp ^alias\."
My advice is to share this .gitconfig file with your colleagues. In my previous project, the team used a standard set of aliases. This helped everyone support each other extremely quickly via the terminal because everyone understood each other’s shortcuts.
Two Crucial Rules to Avoid Disaster
Using Aliases is great, but there are painful pitfalls. I once aliased the force push command to git pf. While half-asleep, I accidentally typed git pf on the production branch instead of my personal branch. As a result, I overrode the entire team’s code.
Keep these two principles in mind:
- Never alias dangerous commands: Commands like
push --forceorreset --hardshould be typed out in full. Those few seconds of typing are a necessary pause for your brain to wake up before hitting Enter. - Don’t forget the original commands: If you have to work on a client’s server or a colleague’s machine, you’ll become extremely clumsy if you’re too dependent on aliases.
Optimizing Git Aliases isn’t just about typing fewer characters. It’s about mastering your tools so you can focus entirely on code logic. Start with 3-5 basic aliases today and feel the difference in your productivity.

