I've spent most of this week talking about business. But today I really wanted to share a cool tool with you. If you're a fan of using Git on the command line you'll love this. I'm going to show you how to use git bisect
to find bugs. It will help you narrow down when exactly a bug was created.
You'll find this very helpful when you start working on repositories that have hundreds of contributors (WooCommerce has more than 300!). Many times it's hard to figure out exactly when a bug was created and with hundreds of commits between releases it's critical you know how to go through them quickly.
Git Bisect
I created a video that shows the whole process. In nine steps and three minutes I was able to go through 500+ commits to find the bug. A bug that I made a couple months ago and had completely forgotten.
Summary
You'll have to use git on the command line. If you use some sort of application for managing git repos you'll have to see if this feature is available in your application (I doubt it).
- Start the process with
git bisect
- Checkout a commit with the bug and then use
git bisect bad
- Next find a tag or commit without the bug and use
git bisect good {sha or tag name}
- Now go through the steps in git bisect and enter either
git bisect good
orgit bisect bad
depending on if you can find the bug - After you're done you can use
git bisect reset
to end the process
I want to thank Brian Richards for this post. I ran into a bug a few months ago and he suggested this method. I've been using it ever since.