Menu

1 / 2

5 Git Commands I Wish I Knew 5 Years Ago

DEV Community: productivity·z z·5 months ago
#GZstmgdu
#dev#commit#bisect#push#article
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.