We’ve all been there. You pull the latest changes, make a few commits, accidentally reset the wrong branch, or spend half an hour trying to work out when a bug was introduced.
Git is one of the most powerful tools in a developer’s toolbox, but most of us only scratch the surface. We learn git add, git commit, git push, and git pull, then stop exploring.
These are five Git commands I’ve found incredibly useful – commands that don’t get nearly as much attention as they deserve, yet have saved me hours of frustration.
1. git reflog — Your Safety Net
Imagine this.
You’ve just run:
git reset --hard HEAD~3
Three commits disappear.
Your heart sinks.
The good news? Git almost certainly still knows where they are.
That’s where git reflog comes in.
git reflog
Example output:
8f6d8c1 HEAD@{0}: reset: moving to HEAD~3ab43f9a HEAD@{1}: commit: Fix authentication bugd29ac77 HEAD@{2}: commit: Refactor login service
You can restore the previous state with:
git reset --hard HEAD@{1}
Why it’s useful
Unlike git log, which shows commit history, git reflog records every movement of your HEAD, including resets, rebases, branch switches, and accidental mistakes.
If you’ve ever thought “I’ve lost my work”, git reflog should be the first command you reach for.
2. git bisect — Let Git Find the Bug
A bug appears in production.
You know it wasn’t there last month.
Since then, there have been 300 commits.
Checking each commit manually isn’t exactly appealing.
Instead:
git bisect startgit bisect badgit bisect good <last-known-good-commit>
Git will now perform a binary search through your commit history.
After testing each suggested commit, simply tell Git whether it’s good or bad.
Eventually, Git pinpoints the exact commit that introduced the issue.
Why it’s useful
Searching 300 commits manually could take hours.
Using binary search, Git narrows that down to roughly 9–10 checks.
It’s one of those features that’s incredibly clever yet surprisingly underused.
3. git worktree — Work on Two Branches at Once
Suppose you’re halfway through implementing a feature when a colleague asks you to review an urgent bug fix.
Normally, you’d:
- Stash your changes
- Checkout another branch
- Review the code
- Switch back
- Apply the stash
- Hope nothing conflicts
Instead, use a worktree.
git worktree add ../bugfix bugfix-branch
Git creates another working directory linked to the same repository.
Now you have:
project/project-bugfix/
Each folder has its own checked-out branch.
No stashing.
No switching.
No interrupted flow.
Why it’s useful
This is particularly useful when you’re juggling feature development, code reviews, or hotfixes.
It’s one of Git’s most underrated productivity features.
4. git restore — Undo Without the Confusion
For years, I used:
git checkout file.txt
to discard changes.
It worked – but checkout was overloaded with multiple responsibilities.
Modern Git introduced a much clearer command:
git restore file.txt
Want to unstage a file?
git restore --staged file.txt
Why it’s useful
The command does exactly what its name suggests.
Instead of remembering all the different ways checkout behaves, you can think:
Restore a file →
git restore
Simple.
5. git blame — Understand the Story Behind the Code
Despite the name, git blame isn’t about pointing fingers.
It’s about answering questions like:
Why does this line exist?
Run:
git blame app.js
You’ll see who last modified each line, when they changed it, and the commit responsible.
From there, you can inspect the commit message to understand the reasoning behind the change.
Why it’s useful
Some code looks strange for a reason.
Maybe it works around a production bug.
Maybe it’s preserving backwards compatibility.
Before deleting something that “looks unnecessary”, checking git blame can save you from introducing a new bug.
Final Thoughts
Git has a reputation for being complicated, but many of its most useful features are hidden just beneath the surface.
If you’re already comfortable with the basics, I’d encourage you to try one of these commands this week. You don’t need to master them all overnight – just adding git reflog or git worktree to your toolkit can make your day-to-day workflow noticeably smoother.
Sometimes the best productivity improvements don’t come from learning a new framework or IDE. They come from getting a little more out of the tools you already use every day.
Have I missed one?
What’s the most underrated Git command you’ve come across? I’d love to hear about it – I’m always looking for another trick to add to my own workflow.


Leave a comment