Skip to content
Go back

10 Git Commands Every Developer Should Know

Updated: (Originally published 21 Sep, 2025 )

Working with Git day-to-day can feel like second nature—until you hit one of those moments where you wish you knew the right command.

After years of tripping over the same pain points, here’s a practical list of Git commands that act like superpowers.


1. git reflogThe Time Machine

Accidentally deleted a branch? Reset to the wrong commit? Reflog is your safety net.

git reflog
# Find your lost commit hash
git checkout -b recovery-branch <hash>

  1. git bisect – The Bug Hunter

You know something broke, but not when? Let Git binary search it for you.

git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Git guides you to the offending commit

  1. git stash --include-untracked – The Context Switcher

Need to switch branches but don’t want to commit messy work?

git stash push -u -m "work in progress on feature X"
# Do work on another branch
git stash pop

  1. git cherry-pick – The Surgical Strike

Grab just the commit(s) you want from another branch.

git cherry-pick <commit-hash>

# Or for a range:
git cherry-pick <start-hash>^..<end-hash>

  1. git worktree – The Parallel Universe

Work on multiple branches at once in separate directories.

git worktree add ../feature-branch feature-branch
# Now you have two working directories for the same repo

  1. git clean – The Janitor

Clear out untracked files and directories. Perfect for cleaning up after switching branches.

git clean -fd

  1. git shortlog – The Historian

Summarize commits by author or message. Useful for release notes or contributor stats.

git shortlog -sn

  1. git blame – The Detective

Find out who last touched a specific line of code.

git blame <file>

  1. git log --graph – The Storyteller

Get a clean, visual commit history.

git log --graph --oneline --decorate --all

  1. git reset – The Undo Button

Rollback commits safely, either keeping or discarding changes.

# Keep changes staged
git reset --soft <commit>

# Discard changes completely
git reset --hard <commit>

Honorable Mentions: Modern Alternatives


Wrapping Up

These aren’t obscure tricks — they’re practical tools that save time, frustration, and sometimes entire projects. Mastering them means fewer “oh no” moments and faster context switching.


Share this post on:

Previous Post
Building a Headless YouTube Playlist Generator with OAuth and Quota Management
Next Post
Cleaning Up GitHub Notifications with Python