Let's be honest.
You've been using Git the same way since 2017.
add .
commit -m "fix"
push origin main
Pray it doesn't break.
But Git is ancient in tech years, and it's packed with commands that most developers have never touched—commands that could save you hours, prevent disasters, and make you look like a wizard in code reviews.
Here are 5 Git commands you probably don't know (but absolutely should).
1. git stash -u
You already know git stash.
But did you know it doesn't stash new files by default?
That's right. git stash ignores untracked files.
You've been switching branches leaving half-written junk behind like a monster.
Fix it:
git stash -u
The -u flag includes untracked files. Your future self will thank you.
2. git rebase -i HEAD~n
Interactive rebase is terrifying the first time you use it.
But once you learn it, you'll never go back.
Want to squash those 14 "wip" commits into one clean commit before pushing?
git rebase -i HEAD~14
It opens an editor. You pick, squash, reword.
Your PR will finally stop embarrassing you.
3. git log --graph --oneline --decorate
You've been staring at git log like a caveman.
Try this instead:
git log --graph --oneline --decorate
It shows you a beautiful ASCII map of your branches, commits, and where HEAD really is.
No more guessing.
(Yes, alias this to git tree immediately.)
4. git bisect
Something broke. You don't know when.
You could check out 50 commits manually like it's 1999.
Or:
git bisect start
git bisect bad HEAD
git bisect good known-good-commit
Git checks out a commit halfway between. You test. You say git bisect good or git bisect bad.
It binary-searches until it finds the exact commit that ruined everything.
It's like magic. But real.
5. git reflog
This one saves careers.
Made a horrible mistake?
Rebased the wrong branch?
Hard reset into oblivion?
git reflog shows everything you've done locally—even commits that aren't in any branch anymore.
Find the commit hash before the disaster and:
git reset --hard hash
You just traveled back in time. You're welcome.
Bonus: The Alias You Actually Need
Add this to your .gitconfig:
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
Now type git lg and watch your terminal look beautiful.
You're Welcome
Git is old. Git is janky.
But Git is also deep.
Stop using the same 3 commands.
Learn the rest. Your future self—and your teammates—will thank you.
Got a Git command that changed your life? Drop it in the comments. I'm genuinely curious.
This markdown is ready to copy and paste directly into dev.to's editor. The formatting is clean, code blocks are properly fenced, and it maintains all the original personality and structure of your post.
Top comments (0)