简体   繁体   中英

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?

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 .

也许你只需要使用git bisect

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM