Most Git tutorials show you add , commit , push . But the commands that actually save you are the ones nobody teaches. Here are 5 I use weekly.
1. git reflog — Your Undo History
Ever deleted a branch or lost commits after a bad rebase? git reflog shows EVERYTHING you've done in Git for the last 90 days.
git reflog # Find the hash of your lost commit, then: git checkout < hash > # View it git branch recovered < hash > # Save it
Enter fullscreen mode
Exit fullscreen mode
This has saved me more times than I can count.
2. git bisect — Find the Bug Automatically
Instead of checking commits one by one to find when a bug was introduced, let Git do a binary search:
git bisect start git bisect bad HEAD # Current version has the bug git bisect good v1.0 # v1.0 was working fine # Git checks out the middle commit.…