DEV Community

Discussion on: Git Bisect — And Debugging Is Easy

Collapse
 
abdurrkhalid333 profile image
Abdur Rehman Khalid

Hmmm Your Article and Idea Seems Very Nice, But Why We have to use something else if we can use the Git only, and Reverse the Commit that is causing the error? It is very simple to go to a specific commit and look for the error at that commit, instead of learning a new thing and then implementing that thing in the project.

Collapse
 
noaabarki profile image
Noaa Barki

First, thank you for your feedback😊

When you have a broken version of your code and you want to locate when(the specific commit) it got broken you will probably need to check-out each commit, build your app and check if the bug still exists, this called a linear search and while it’s very simple and easy to understand it can take a lot of time and effort when there are hundreds of commits. That is exactly what the git bisect command does only with binary search which is more efficient then a linear search.
As Elcio said the git bisect command helps you find the commit where the bug interduced. However, if you already know on which commit it happened then you don't need the git bisect at all. 😎

Collapse
 
abdurrkhalid333 profile image
Abdur Rehman Khalid

That's Very Nice To Mention Here and For Sure Looking Forward to Give it a try as well.

Collapse
 
simme profile image
Simme

Git bisect is built into git, so it's not "something else".

Collapse
 
elcio profile image
Elcio Ferreira

And how do you know what commit is causing the error? If you don't find the error as soon as it was caused, you will need to check commits one by one or do some binary search. That's where git bisect helps you. It automates the binary search work.