如何更改提交中的代码以帮助查找错误?

发布于 2024-11-08 13:18:46 字数 115 浏览 11 评论 0原文

我正在尝试追踪代码中的特定错误,但问题是该错误出现在提交块中的某个位置,其中检查提交是否中断的唯一方法已被注释掉,因此我看不到它是哪个提交。

我需要更改一行代码,并将该行合并为多个提交,可以这样做吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟沫凡尘 2024-11-15 13:18:46

在提交块中查找具有特定行为的第一个(或最后一个)提交的最佳方法是使用 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.

生生漫 2024-11-15 13:18:46

也许您只需要使用 git bisect ?

Perhaps you just need to use git bisect?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文