As a senior dev using Git for a while now, but every so often, I stumble across a command that makes me go, “Wait, you can do that?” This post is a little collection of Git tips and tricks I recently discovered—some are super handy, others just plain cool. Hopefully, they'll make your Git life a bit easier too.


🔍 git grep — Search Like a Pro

Ever needed to find a piece of text across your whole project? git grep is like grep, but smarter for Git repos. It skips build folders and knows what files are actually tracked by Git, so it's faster and cleaner.

You can level it up with a few options:

  • --pattern-type=perl lets you use Perl-style regex for advanced searches
  • --line-number (or set grep.lineNumber=true in your config) shows you where the match is in the file

🕰️ git reflog — Your Undo Button

Made a mistake and don’t remember where things went wrong? git reflog is your safety net. It shows a log of all the changes to your branch pointers—including commits, rebases, and checkouts—even the stuff you thought was lost forever.

Helpful flags:

  • --date=iso gives you readable timestamps
  • --pretty makes the output more human-friendly

Seriously, if you ever feel like you “lost” a commit, this is your best friend.


📜 git blame -C -C -C — Who Wrote This?

git blame shows you who changed each line in a file and when. Great for figuring out why something is the way it is. Adding -C -C -C makes it even smarter—it can track code that was copied or moved between files or commits.

It’s like detective mode for your repo.


♻️ git rerere — Conflict Resolution on Autopilot

Merging or rebasing can be a pain when the same conflicts pop up again and again. Enter git rerere.

If you turn it on (git config rerere.enabled true), Git will remember how you fixed a conflict. Next time it sees the same one, it’ll resolve it for you automatically. Total time-saver.


🕵️‍♂️ git recover — Find the Uncommitted

This one’s technically not a Git command, but a separate tool you can find here.

Ever added a file with git add and then forgot to commit it… and now it’s gone? git recover can dig into the object database and help you find those "lost" files. It's like a metal detector for your Git history.


Got any under-the-radar Git tricks you love? Drop them in the comments below.

Happy committing! 🚀