Git Beyond the Basics: Stash, Cherry-Pick, and Bisect

Beyond add, commit, and push, Git has genuinely powerful commands most developers never learn — worth the investment since they solve real, recurring problems.

# git stash: temporarily shelve uncommitted changes without committing them
git stash                    # save current changes, revert to a clean working directory
git stash pop                 # restore them later
git stash list                 # see all stashed changes
git stash apply stash@{2}      # apply a specific stash without removing it from the list

# git cherry-pick: apply a specific commit from another branch
git cherry-pick abc1234         # useful for backporting a single fix to a release branch

# git bisect: binary search through history to find which commit introduced a bug
git bisect start
git bisect bad                  # current commit is broken
git bisect good v1.2.0           # this older commit was known good
# Git checks out commits one at a time; you mark each 'good' or 'bad'
# until it pinpoints the exact commit that introduced the bug

git bisect Deserves Special Mention

For a bug that “used to work” somewhere in a long, unclear commit history, bisect automates a binary search through your commits — testing roughly log₂(n) commits instead of manually checking every single one, turning a tedious multi-hour hunt into a handful of targeted tests.