A Faster Way to Track Down Bugs
Have you ever spent all day searching through commits for a bug? Use this git bisect to literally cut your time in half!

Developer Advocate @ GitHub
Search for a command to run...
Have you ever spent all day searching through commits for a bug? Use this git bisect to literally cut your time in half!

Developer Advocate @ GitHub
No comments yet. Be the first to comment.
In this series, I will document technical tutorials for navigating GitHub's awesome features!
My manifesto of AI-Driven Learning
Raise your hand if you've been personally victimized by the question: 'Will AI replace software engineers?' It's a common debate that drives developers to extremes—either avoiding AI entirely or frantically signing up for every AI course available. ...
I recently went down several rabbit holes about building WYSIWYG editors and popovers. While on maternity leave, I finally have time to deeply explore random technical problems without deadlines - a rare opportunity. Thus far, I've focused on contrib...
This blog post uses storytelling to introduce beginners to Verifiable Credentials, followed by a tutorial on creating them in JavaScript and Kotlin. In Our Last Issue... In our previous issue, we met Dawson Webhart, a junior frontend software enginee...

"Our current credit system says, 'Saddle yourself, so we can give you more to saddle.'" Eric Lapin, President of FormFree, stated during a recent TBD live stream. His comment sheds light on a fundamental paradox of the U.S. credit system: it often re...

Technology adoption doesn't happen with one software engineer coding in solitude. Even though big companies like Meta and Microsoft boast of their humble beginnings in a dorm room or a garage, product adoption requires good marketing. Many software e...

Black Girl Bytes
58 posts
I'm a Developer Advocate at GitHub. I'm passionate about community, code, and education! Reach out to me on Twitter ❤️
Most of my time working as a software engineer is spent tracking down and fixing bugs. While a good portion of the bugs are my own doing, some of the bugs were created by other engineers, which makes the task more ambiguous. As the codebase grows, finding bugs becomes increasingly difficult. It's a time sink and super boring to manually click through every suspicious commit to find the culprit. However, you can automate this process by using a tool called git bisect.
Git bisect is based on a binary search algorithm, but don't worry, you won't need to dust off your old data structure textbooks! Git does all the work of repetitively dividing the commits in half, checking out commits, and helping you identify when new changes were introduced.
To let git know you want to start the process run :
git bisect start
git bisect good
git bisect bad
Git will checkout a commit between the two commits you provided. It will ask you to determine if that commit is good or bad, so play around with that copy of your code and see if the bug still exists. If it still exists, run git bisect bad again. Git will continue to narrow down the commits until you find the culprit -- allowing an easier process of elimination. Using this, I realize I had the advantage of expending less brain power on finding the bug and more brainpower on fixing it.
If so, run:
git bisect reset
This will tell git to stop bisecting. Then you can check out the offending commit, and start refactoring.
⚠️ Warning: For this to work well, you will need a linear commit history.
Without a linear commit history, the history wouldn't show a true reflection of when code changes were made. To achieve a linear history, utilize git rebase and git squash and merge.
Comment below to tell me if it worked for you!