Binary search for bugs
Tracking bugs 🐛 in big projects is tricky. A couple of merges a day by multiple developers can introduce subtle bugs.
It doesn’t work right now but you know it worked last week.
To quickly find out which commit introduces a bug you can use git bisect.
It’s binary search for the commit you’re looking for.
How to use it:
- You start the git bisect session with
git bisect start
- Then you tell it that the current commit is bad
git bisect bad
- We need to know what commit/tag was working
git bisect good 92498b
- Git will checkout to other commits and ask you if your software works on this commit
- Type either
git bisect good
orgit bisect bad
- After a while, you’ll find the commit which introduced the issue.
🫵 If you enjoyed this article you can join my newsletter to get dose of weekly craftsmanship