git bisect没有响应命令

时间:2016-08-18 15:35:01

标签: git git-bisect

我在一个名为redesign-test-fixes的单独分支上,我正在运行git bisect start。之后,我测试我的错误并运行git bisect bad。终端打印无输出。然后我运行git bisect good。同样的事情,终端上没有打印输出。就像bisect一开始没有运行一样。通常我希望终端输出有关剩余步数的信息。怎么了?怎么解决这个问题?我是否处于一种不允许我运行二等分的git状态。

git状态响应:

On branch redesign-test-fixes
nothing to commit, working directory clean

但是,如果我运行git bisect start,git状态会响应:

On branch redesign-test-fixes
You are currently bisecting, started from branch 'redesign-test-fixes'.
  (use "git bisect reset" to get back to the original branch)

nothing to commit, working directory clean

1 个答案:

答案 0 :(得分:7)

您错误地使用了git bisect。输入git bisect start后,您需要为git bisect提供一系列提交才能使用。此范围由“良好”提交定义,在该提交中,您确定不会出现错误,然后是“错误”提交,您认为该错误肯定存在。因此,您的使用应该从这样开始:

git bisect start
git bisect good <SHA-1 of good commit>
git bisect bad  <SHA-1 of bad commit>

假设你在坏的和好的之间有20个提交,那么你应该看到输出看起来像这样:

Bisecting: 10 revisions left to test after this (roughly 4 steps)

剩下10个修订版的原因是因为Git已经检查了你选择范围内的中间提交,并且它知道大多数 10个提交需要检查才能找到提交错误的地方。

接下来,您需要在此中间提交中检查您的应用程序,并确定该错误是否存在。如果您没有找到错误,请输入:

git bisect good

如果你看到错误,请输入:

git bisect bad

这将再次显示输出如下:

Bisecting: 5 revisions left to test after this (roughly 2 steps)

在没有明确告诉你的情况下,Git再次检查了新范围的中间提交。

您将继续这个键入git bisect good/bad的过程,当没有任何内容可以平分时,Git会向您显示第一个错误提交:

a8h39dk32... is the first bad commit

进一步阅读:

以下是great tutorial的链接,其中涵盖git bisect的完整用法。我发现即使官方的Git文档也不完全彻底。

相关问题