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 4.7.0.310, and the earliest bad version is 4.7.0.311, 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:
1
|
|
Starting the git bisect command:
1
|
|
Marking the good version and the bad one with the tag name (or commit id):
1 2 |
|
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:
1
|
|
If the build failed, then mark it bad:
1
|
|
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:
1
|
|
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 |
|
Done!
Written with StackEdit.