← Learning Hub
Advanced

Stash, Cherry-pick, Blame and Bisect

Stash puts unfinished work aside so you can switch tasks quickly, like putting papers in a drawer. Cherry-pick copies one specific commit from another branch - handy for applying a single bug fix without merging everything.

stash: put work aside for a moment

Example
git stash push -m "half-done search box"   # save uncommitted changes, clean the folder
git switch main                             # ...fix an urgent bug...
git switch feature-search
git stash list
# stash@{0}: On feature-search: half-done search box
git stash pop                               # bring the changes back

cherry-pick: copy one commit

Need just one fix from another branch? Copy that single commit onto your current branch.

Example
git cherry-pick 4f2c9a1

blame: who changed this line, and when?

Example
git blame src/cart.js -L 40,55
# 9a4b6e3 (Ravi Kumar 2026-11-02 14:10) const total = items.reduce(...)

Use it to find the commit behind a line, then read that commit's message for the why - not to blame people.

bisect: find the commit that broke something

Something worked last week and is broken now, with 200 commits in between. git bisect does a binary search through history: about 8 tests instead of 200.

Example
git bisect start
git bisect bad                 # the current version is broken
git bisect good v1.4.0         # this older version worked
# Git checks out a commit in the middle - test it, then say:
git bisect good                # or: git bisect bad
# ... repeat until:
# 7d3e1f0 is the first bad commit
git bisect reset               # go back to where you started
Bisect is binary search - the same idea from the DSA course, used on your project's history.
Key points
  • git stash saves unfinished work; git stash pop brings it back.
  • git cherry-pick copies one commit.
  • Use them for quick context switches and targeted fixes.

📝 Test yourself

1. What does git stash do?
2. Which command finds the commit that introduced a bug?
3. Fill in the command that copies one commit to the current branch:
git 4f2c9a1