When some changes broke your build during the mid night, how to find the culprit of the failure very quickly? Like this:
If you are using git as your version control system, then the short answer is ‘git bisect’.
As the above screenshot, you know the latest good version is 126.96.36.1990, and the earliest bad version is 188.8.131.521, so some changes between the two version failed the build. Then how to use ‘git bisect’ to help us debug the issue very quickly?
Firstly, checking out the source tree to an environment:
Starting the git bisect command:
Marking the good version and the bad one with the tag name (or commit id):
Then git bisect analyzes the changes between, checkout the middle one (bisected) to the current environment and wait for verification. What we need to do now is just to run the build command to get the build result for the snapshot:
If the build failed, then mark it bad:
Git should checkout another version between this one and the good one, bisectedly. Then what we need to do is to run the build command again to get the build result:
If the build is successful, then git should bisect to another version between this one and the latest verified bad one. Until git find which commit failed the build.
Assuming you mark the build is successful, and git find out which commit is the root cause, it should display the commit after the mark command immediately:
1 2 3 4 5 6 7 8 9 10
Written with StackEdit.