⭐ Introduction
Git is one of the most powerful tools we use every day, but some commands are long to type and easy to forget. Git Aliases help us create shortcuts for frequently used commands so we can work faster, make fewer mistakes, and keep our workflow smooth.
This post lists the most useful Git aliases that every developer — beginner or expert — should know. They are easy to set up and make Git feel simpler and more enjoyable.
🧠 What Are Git Aliases?
A Git alias is like a nickname for a long command.
Example:
Without alias:
git status
With alias:
git s
Git will understand both.
You just type the shorter version and save time.
Aliases work in:
- Git CLI
- VS Code terminal
- GitHub Codespaces
- Linux, macOS, Windows
- Dev Containers
Once added to your Git config, they work everywhere.
⚙️ How to Create a Git Alias
Use this format:
git config --global alias.<shortcut> "<full-command>"
Example:
git config --global alias.s "status"
Now typing git s will show the same output as git status.
🚀 Must-Have Git Aliases (Highly Recommended)
These shortcuts speed up your daily workflow instantly.
1. Check your Git status quickly
git config --global alias.s "status"
Use it:
git s
2. Create branches faster
git config --global alias.br "branch"
Use it:
git br
3. Switch branches easily
git config --global alias.co "checkout"
Use it:
git co main
4. Commit with a message quickly
git config --global alias.cm "commit -m"
Use it:
git cm "Initial commit"
5. View clean, readable commit logs
This is one of the most useful aliases.
git config --global alias.lg "log --oneline --graph --decorate --all"
Use it:
git lg
You’ll see a beautiful branch graph.
🔄 Helpful Aliases for Everyday Work
6. Add all changes quickly
git config --global alias.a "add ."
Use it:
git a
7. Pull with rebase (cleaner history)
git config --global alias.pl "pull --rebase"
Use it:
git pl
8. Undo last commit (safely)
git config --global alias.uncommit "reset --soft HEAD~1"
Use it:
git uncommit
This keeps your changes but removes the commit.
9. Stash and continue
git config --global alias.ss "stash save"
git config --global alias.sp "stash pop"
Use them:
git ss "temp changes"
git sp
10. See which files changed (simple view)
git config --global alias.df "diff --name-only"
Use it:
git df
✨ Bonus: Super-Productive Advanced Aliases
These are optional but powerful.
11. Show changes in a readable format
git config --global alias.d "diff --color"
12. View last commit quickly
git config --global alias.last "log -1 HEAD"
Use it:
git last
13. Clean up merged branches
git config --global alias.cleanup "!git branch --merged | grep -v 'main' | grep -v 'master' | xargs -n 1 git branch -d"
Use it:
git cleanup
🚀 Why Git Aliases Make You Faster
Using aliases gives you benefits like:
- Less typing
- Fewer mistakes
- Cleaner Git history
- Faster context switching
- A smoother developer experience
- Works on local machine, VS Code, and Codespaces effortlessly
Every second saved in Git adds up over weeks and months.
🎉 Conclusion
Git aliases are simple but incredibly powerful. With just a few lines of configuration, you can transform your Git workflow and make everyday tasks much faster.
Start with the basic aliases in this post, and add more as you discover what fits your style. Once you get used to them, you’ll never want to go back to typing long Git commands again.
Happy coding! 🚀