简体   繁体   English

如何查找包含错误的提交

[英]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. 我在本地计算机上工作,对事物进行了重构(包括A,B,C,D),我始终确保输出文件没有更改。 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? 我如何找到更改的确切提交(E,F,G,H)是什么?

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

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

Thank you! 谢谢!

You are after git bisect . 你是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 (eg 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. 另外,如果可以自动确定输出文件是否已使用脚本进行了更改,则可以将该脚本指定为git bisect ,它将自动运行该脚本来确定好,坏或未知,因此您可以等待结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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