Library › Book 17 › Git Bisect and Cherry-Pick -- Hunting Regressions and Applying Targeted Fixes
Git Bisect and Cherry-Pick -- Hunting Regressions and Applying Targeted Fixes
5.1🔒The Detective's ToolkitWhen a test that used to pass is now failing, you need to find the exact commit that introduced the regression. Manually checking dozens or…
5.2🔒How Bisect WorksYou tell Git one "good" commit (where the test passed) and one "bad" commit (where the test fails). Git checks out the midpoint and asks…
5.3🔒Manual Bisect: Step by StepPro Tip: Always use git bisect reset when you are done. Bisect puts you in a detached HEAD state, and forgetting to reset is a common…
5.4🔒Automated Bisect: Let Git Do the WorkThe real power of bisect is automation. Give Git a command that exits with 0 (good) or non-zero (bad), and it runs the entire bisect…
5.5🔒When to Use BisectBisect is invaluable because it gives you a specific commit, author, and description to reference in your bug report. "This regression was…
5.6🔒The Bisect Murder Mystery ExerciseThis is a hands-on exercise where you set up a repository with a hidden regression and use bisect to find it -- like a detective solving a…
5.7🔒Cherry-Pick: Targeted Commit ApplicationCherry-pick applies a specific commit from one branch to another without merging the entire branch. It creates a new commit with the same…
5.8🔒Common Scenarios for Cherry-PickYou fixed a flaky test on develop, but the same test is flaky on the release/2.4 branch.
5.9🔒Cherry-Pick Best Practices- Cherry-pick creates a new commit: The original and cherry-picked commits have different hashes. Git does not know they are related…
5.10🔒Combining Bisect and Cherry-Pick: The Full WorkflowA powerful regression-hunting workflow:
5.11🔒Exercises1. Complete the Bisect Murder Mystery exercise from Section 5.5 using manual bisect. 2. Repeat the exercise using automated bisect (git…
5.12🔒Career Translation- Used git bisect to identify regression-introducing commits in a 10,000-commit codebase, reducing average root cause investigation time…
5.13🔒Q&AInterview Depth CheckPrompt: A critical E2E test for the checkout flow started failing sometime in the last two weeks. There have been 150 commits since the…