Skip to main content
Code and think

GIT Bisect - find the bad commit

To find a bad commit you can use git bisect.

For example, you used the git log in order to identify that the issue was not present 10 commits ago. Besides, you have a command (e.g. build, test, etc.) to validate the presence of the issue. Use the following steps to let git find the issue for you:

git bisect start HEAD HEAD~10 --    #git bisect start BAD LAST_KNOWN_GOOD
git biset run sh -c "make || exit 125; ~/check_test_case.sh"
git bisect reset

Note: on Windows you can run multiple commands like:

...
git bisect run pwsh -command "make && check_test_case.ps1"
...

Reference