gitmergecommitgit-bisect

How can I change code within a commit to help find a bug?


I am trying to track down a specific bug in my code, but the trouble is the bug appeared somewhere in a block of commits where the only way to check if the commit breaks is commented out, so I can't see which commit it is.

I need to change one line of code, and have that line merge into several commits, can this be done?


Solution

  • The best way to find the first (or last) commit with a certain behaviour in a block of commits is to use git bisect. More specifically: git bisect run.

    To automate the entire process you need to write a script which comments out the one line in question and then starts a test. the script should exit with code 0 if the code is good and code 1 if the code is bad.

    For an example read here: http://www.metaltoad.com/blog/mechanizing-git-bisect-bug-hunting-lazy.