如何更改提交中的代码以帮助查找错误?
我正在尝试追踪代码中的特定错误,但问题是该错误出现在提交块中的某个位置,其中检查提交是否中断的唯一方法已被注释掉,因此我看不到它是哪个提交。
我需要更改一行代码,并将该行合并为多个提交,可以这样做吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在提交块中查找具有特定行为的第一个(或最后一个)提交的最佳方法是使用
git bisect
。更具体地说:git bisect run
。要自动化整个过程,您需要编写一个脚本,注释掉有问题的一行,然后开始测试。如果代码良好,则脚本应以代码 0 退出;如果代码不好,则应以代码 1 退出。
有关示例,请阅读此处:http://www.metaltoad。 com/blog/mechaniizing-git-bisect-bug-hunting-lazy。
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 ?
Perhaps you just need to use
git bisect
?