Quick Wins with Git That Most Developers Miss

Quick Wins with Git That Most Developers Miss

You're already using Git, probably multiple times a day. But there's a handful of commands sitting right there that could save you legitimate hours every week.

What's the fastest way to undo my last commit without losing work?

Git reset --soft HEAD~1 pulls back your last commit but keeps all the changes staged. I use this constantly when I realize I forgot to include a file or wrote a terrible commit message. Takes two seconds, saves the awkward "oops, one more thing" commit.

How do I grab just one commit from another branch?

Cherry-pick is your answer. git cherry-pick abc123 pulls that specific commit into your current branch. Perfect when someone fixed a critical bug on another branch and you need it now, not after the whole feature merges.

Can I search through my entire Git history?

Yes, and it's incredibly useful. git log -S "database connection" searches every commit for that exact string. I've found deleted code this way dozens of times. When someone asks "didn't we have a function that did X?" - this finds it in under a minute.

What about seeing changes before I pull?

Git fetch followed by git diff HEAD origin/main shows you exactly what's coming without actually merging anything. Prevents those surprise conflicts when you're in the middle of something.

Is there a shortcut for switching between two branches?

Git checkout - (just a dash) toggles between your current branch and the last one you were on. Like alt-tab for branches. Sounds minor until you're reviewing a pull request while working on a feature.

These aren't advanced techniques. They're standard Git functionality that somehow never makes it into the typical workflow tutorials. Start with one, use it until it's automatic, then add another.

Cookie Preferences

We use cookies to enhance your browsing experience and analyze site traffic. Choose your preferences below.

Required for basic site functionality. Always enabled.

Help us understand how visitors interact with our site.

Used to deliver personalized content and advertisements.