aptypr
aptypr

Reputation: 417

How to find what commit contain a bug

I worked on my local computer, refactoring things(commits A,B,C,D), I always made sure that output files didn't change. After merging (commit I) I found that output files changed.

How can I find what exactly commit (E,F,G,H) is the reason of change?

A->B->C->D -I

\E->F->G->H/

Thank you!

Upvotes: 0

Views: 390

Answers (1)

Vampire
Vampire

Reputation: 38724

You are after git bisect. You give it a bad and a good revision and then it checks out the middle between them, waits for you to tell it whether this commit is good, bad or unknown (e. g. because it does not compile in that commit) and then checks out the next middle of the remaining half. This binary search algorithm will very fast give you the commit that changed the output.

Also, if you can automate the process of determining whether the output files changed with a script, you can give that script to git bisect and it will run the script automatically to determine good, bad or unknown so you can just wait for the result.

Upvotes: 3

Related Questions