DEV Community

Cover image for Boost Your Git Productivity: A Simple Dev's Guide to Git Aliases with Real Examples
Rajat
Rajat

Posted on

Boost Your Git Productivity: A Simple Dev's Guide to Git Aliases with Real Examples

Ever feel like you're typing the same long Git commands over and over again?


Ever feel like you're typing the same long Git commands over and over again?

If you're a developer (especially a frontend or Angular developer), Git is part of your daily life. But let me ask you: What if you could save time, avoid typos, and streamline your Git workflow — all by typing just a few letters?

By the end of this article, you'll know:

  • ✅ What Git aliases are and why they matter
  • ✅ How to create your own Git aliases (with real examples)
  • ✅ Some must-have aliases for frontend developers
  • ✅ How to make them global and persist across projects
  • ✅ Bonus: How to alias complex commands and combine flags like a pro

So grab a cup of chai (or coffee ☕) — let's optimize your Git life.


🚀 What Are Git Aliases?

A Git alias is a custom shortcut you define to avoid typing long or repetitive commands.

Think of it like a speed dial for Git.

Instead of typing:

git status

Enter fullscreen mode Exit fullscreen mode

You can just type:

git s

Enter fullscreen mode Exit fullscreen mode

And it works the same. Magic? Nope. Just smart config.


🛠️ How to Set Up a Git Alias (Step-by-Step)

Git stores aliases in your .gitconfig file.

To add one, you can run this command:

git config --global alias.s status

Enter fullscreen mode Exit fullscreen mode

Now whenever you type:

git s

Enter fullscreen mode Exit fullscreen mode

It will run git status. Simple, right?


🔥 Must-Have Git Aliases for Developers

Here are some popular and time-saving aliases:

git config --global alias.s status
git config --global alias.c commit
git config --global alias.ca 'commit -a'
git config --global alias.cm 'commit -m'
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.hist "log --oneline --graph --decorate --all"

Enter fullscreen mode Exit fullscreen mode

🧠 Tip: You can open your ~/.gitconfig file and edit aliases manually too.


🧪 Demo: My Favorite Git Alias – The “Hist” Log View

This one is a game-changer for visualizing branches:

git config --global alias.hist "log --oneline --graph --decorate --all"

Enter fullscreen mode Exit fullscreen mode

Then just run:

git hist

Enter fullscreen mode Exit fullscreen mode

And you'll see:

* a3c9d22 (HEAD -> main) Updated README
* 934a7cd (feature/login) Added login logic
* e1a8e5b Initial commit

Enter fullscreen mode Exit fullscreen mode

It’s like Git turned visual!


🧬 Advanced Git Aliases (with Parameters)

Yes, you can alias even complex commands like this:

git config --global alias.undo "reset --soft HEAD~1"

Enter fullscreen mode Exit fullscreen mode

This gives you the power to "undo" your last commit, keeping changes in staging.

Usage:

git undo

Enter fullscreen mode Exit fullscreen mode

Boom! Like Ctrl+Z for Git commits.


💡 Pro Tip: Use Functions in Bash or Zsh

Want to create more interactive or multi-step Git shortcuts? Use shell functions in .bashrc or .zshrc like this:

gpush() {
  git push origin $(git branch --show-current)
}

Enter fullscreen mode Exit fullscreen mode

Now just type:

gpush

Enter fullscreen mode Exit fullscreen mode

It'll push your current branch automatically.


🧠 Why Devs Should Care

As Angular/React developers, we switch branches, commit often, stash changes, and cherry-pick bug fixes. Git aliases let you do all this faster and error-free.

  • Save time in daily workflows
  • Reduce mental fatigue
  • Look like a pro in front of your team 👨‍💻👩‍💻

🎯 Your Turn, Devs!

👀 Did this article spark new ideas or help solve a real problem?

💬 I'd love to hear about it!

✅ Are you already using this technique in your Angular or frontend project?

🧠 Got questions, doubts, or your own twist on the approach?

Drop them in the comments below — let’s learn together!


🙌 Let’s Grow Together!

If this article added value to your dev journey:

🔁 Share it with your team, tech friends, or community — you never know who might need it right now.

📌 Save it for later and revisit as a quick reference.


🚀 Follow Me for More Angular & Frontend Goodness:

I regularly share hands-on tutorials, clean code tips, scalable frontend architecture, and real-world problem-solving guides.

  • 💼 LinkedIn — Let’s connect professionally
  • 🎥 Threads — Short-form frontend insights
  • 🐦 X (Twitter) — Developer banter + code snippets
  • 👥 BlueSky — Stay up to date on frontend trends
  • 🌟 GitHub Projects — Explore code in action
  • 🌐 Website — Everything in one place
  • 📚 Medium Blog — Long-form content and deep-dives
  • 💬 Dev Blog — Free Long-form content and deep-dives
  • ✉️ Substack — Weekly frontend stories & curated resources
  • 🧩 Portfolio — Projects, talks, and recognitions
  • ✍️ Hashnode — Developer blog posts & tech discussions

🎉 If you found this article valuable:

  • Leave a 👏 Clap
  • Drop a 💬 Comment
  • Hit 🔔 Follow for more weekly frontend insights

Let’s build cleaner, faster, and smarter web apps — together.

Stay tuned for more Angular tips, patterns, and performance tricks! 🧪🧠🚀

✨ Share Your Thoughts To 📣 Set Your Notification Preference

Top comments (0)