DEV Community

Debugging with Git

Nesha Zoric on June 18, 2018

When you are working on a huge project, you may discover bugs in the code that prevent you from proceeding any further in your development. How to ...
Collapse
 
belinde profile image
Franco Traversaro

I don't understand: how does git bisect check if a commit is good or bad? Does have an integration with unit tests?

Collapse
 
maestromac profile image
Mac Siri

There's no integration. It would be up to you to evaluate if a commit is good or bad by either running a test, starting the app locally, or playing with it on repl/console. Git bisect reduces the number of commits you would have to go through with binary search.

Collapse
 
hoelzro profile image
Rob Hoelz

You can also use git bisect run to have Git run your tests - that way if your test suite takes a while, you can leave and make yourself a sandwich or something. When you get back, Git will have done all the work for you!

Thread Thread
 
maestromac profile image
Mac Siri

Well this change everything. Thanks!

Collapse
 
tadaboody profile image
Tomer

Could you please show a debugging session where this helps find the bug? As is I don't think I get the workflow with these tools

Collapse
 
martinhaeusler profile image
Martin Häusler

I sometimes wish that there was a way to do this bisection search faster. It's really a painful process, yet sometimes it cannot be avoided.

Collapse
 
hoelzro profile image
Rob Hoelz

I haven't used it in a while, but I wrote a tool called git-pisect that leverages multiple cores to converge on the offending commit: hoelz.ro/blog/git-pisect

Let me know if it works for you!

Collapse
 
martinhaeusler profile image
Martin Häusler

I'll keep that in mind, thanks!

Collapse
 
michalkleiner profile image
Michal Kleiner

There are two similar commit hashes in the bisect example - 95d69a1, so it's not clear which one will get tagged as good.

Collapse
 
jibinp profile image
Jibin Philipose

Awesome.