Lesson 26 / 28
cherry-pick & bisect
Copy a single commit with git cherry-pick and find the commit that introduced a bug with git bisect.
cherry-pick
git cherry-pick applies one commit from another branch onto your current branch, for example a hotfix.
git switch release/1.2
git cherry-pick a1b2c3d # copy one fix from main
git cherry-pick --abort # if it conflicts and you want outbisect
git bisect binary-searches history. Mark a bad and a good commit, then test each step Git checks out.
git bisect start
git bisect bad # current commit is broken
git bisect good v1.0.0 # this one worked
# test, then run: git bisect good OR git bisect bad
git bisect resetCherry-picking duplicates a commit (a new hash), so prefer merging when you can. Bisect can run automatically with git bisect run ./test.sh.