Sitemap
codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Member-only story

Debug your code using git bisect

--

Press enter or click to view image in full size
Photo by Yancy Min on Unsplash

What’s git bisect?

A few days ago, I first learned about git bisect from this Tweet:

From the very first look of it, I was like — whoosh! This could be awesome. From the main page, it says this -

TLDR; git-bisect — Use binary search to find the commit that introduced a bug

So, that’s kind of our day-to-day software engineering need, amirite? In the middle of our development of a particular feature, somehow we stumble upon a situation where an existing code fragment is broken, but it shouldn’t because we didn’t touch (or actually couldn’t remember) any related codes! What do we do then? Personally, I check out particular commits that I feel suspicious or check the file changes, but that’s a hell lot of work to actually narrow down the bug. To automate this process, we can use git bisect.

This command uses a binary search algorithm to find which commit in our project’s history introduced a bug. First, we have to tell which one is the “bad” commit that is known to contain the bug, most of the cases that’s where the…

--

--

Nayeem Reza
Nayeem Reza

Written by Nayeem Reza

Fullstack Developer at EMBL ▪ Love 🚴 🏔 👨‍🍳 🍻 🎧

codeburst
codeburst

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.