Safety & Recovery · 8 min read · Beginner
Cherry-Pick & Git Bisect
Copy a single hotfix commit across branches with git cherry-pick and pinpoint regressions in O(log n) steps with git bisect.
What you'll learn
- Apply one specific commit onto another branch using git cherry-pick
- Find the exact commit that introduced a bug using binary search (git bisect)
- End a bisect session cleanly with git bisect reset
Sometimes you need one bug-fix commit from a feature branch without merging the entire unfinished branch. git cherry-pick <hash> copies just that commit onto your current branch.
Finding Bugs Fast with git bisect
When a bug appeared somewhere in the last 1,000 commits, git bisect performs a binary search across history, pinpointing the exact offending commit in ~10 steps instead of 1,000.
Fill-in-the-Blank Exercise
Cherry-Pick a Hotfix
Apply commit a1b2c3d onto main and later exit a bisect session.
git a1b2c3d
git bisect Interactive Git Sandbox
GitInspect Commit Hashes for Cherry-Pick
main
(main) $ git status
On branch main Untracked files: index.html, styles.css
Check Your Understanding
Score: 0 / 1
1. What algorithm does git bisect use to find the commit that introduced a regression?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.