How to find the commit that broke something after a merge in Git?

Tracking the commit that introduced a bug after a big merge can be time-consuming. Luckily git offers a great binary search facility in the form of `git-bisect.`

Tracking the commit that introduced a bug after a big merge can be time-consuming. Luckily git offers a great binary search facility in the form of git-bisect. First, you have to perform the initial setup:

 git bisect start         # starts the bisecting session
 git bisect bad           # marks the current revision as bad
 git bisect good revision # marks the last known good revision

After this, git will automatically checkout a revision halfway between the known “good” and “bad” versions; you can now rerun your specs and mark the commit as “good” or “bad” accordingly.

git bisect good # or git bisec bad

This process continues until you get to the commit that introduced the bug.

Originally Posted On: Dev.to

Subscribe to GIT.WTF!?!

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe