I'm going to give you some more information about git bisect.
git bisect helps us find the commit that causes a - very hard to find - bug in our code. Sometimes this bug was introduced more than 50 commits in the past. When you have no idea what causes this bug, git bisect comes to the rescue and finds in which commit it was introduced.Start out by opening your Terminal. git bisect is used from the command line. Navigate to the folder that contains your git repository and start a bisect session using the following command:
$ git bisect start
Once this session is started we have to give a working commit hash. When checking out this commit the bug shouldn't be there:
$ git bisect good a13c42
And now we do the same for the failing commit. In most cases this will be your latest commit:
$ git bisect bad b23d45
Run your tests (or just run the application and test it manually) to check if your bug is still occuring. Tell git bisect that the commit is *bad*. When the code is working as it should, you say the commit is *good*:
$ git bisect bad $ git bisect good
Keep repeating this process until git bisect notifies you when it found the failing commit. git bisect uses binary search to find the bug.
When you found the malicious commit, you should reset your workspace so you can continue with your work:
$ git bisect reset
Manually marking each commit as good or bad can be a long process. Git bisect gives you the possibility to automate this process, it will run the tests for you and mark the commits. Start by initializing git bisect as you did before:
$ git bisect start $ git bisect good a13c42 $ git bisect bad b23d45
Next, tell git bisect which test script to run. You can only automate the git bisect process by running your tests from the command line:
$ git bisect run ./run_test.sh
Everything will run automatically, and you'll be notified when the failing commit is found.
Hope you enjoyed this post, and get some use out of git bisect. I know I did.