1

我知道topic-branch-7的提示有bug,也知道master的提示没有bug。我想找出在 topic-branch-7 中引入错误的位置。所以我运行了以下命令:

git checkout topic-branch-7
# some testing to verify the bug
git bisect start bad  # start a git bisect and mark this commit as bad
git-merge-base master topic-branch-7
9ac8c59bb10c13d86bcdeff90cb47e25d477caad
git checkout 9ac8c59bb10c13d86bcdeff90cb47e25d477caad
# some testing to verify the bug is not present
git bisect good

让我感到震惊的是,当我运行 git bisect good 时……什么也没有发生!难道不应该将提交标记为好,找到这个提交和错误提交之间的中点,然后检查那个提交吗?为什么什么都没有发生?

4

2 回答 2

2

我认为您的 git bisect 语法错误。它应该是

git-merge-base master topic-branch-7
9ac8c59bb10c13d86bcdeff90cb47e25d477caad
git bisect start topic-branch-7 9ac8c59bb10c13d86bcdeff90cb47e25d477caad
#you are now at a commit somewhere in between topic-branch-7 and 9ac8c59bb10c13d86bcdeff90cb47e25d477caad
#do testing to find out if bug is there
git bisect good/bad
#repeat until git tells you where the bug is introduced
git bisect reset HEAD
于 2012-11-27T01:14:14.340 回答
0

我知道 git bisect 工作得很好,但我喜欢做的是使用分支手动完成。我选择一个好的提交并创建一个分支,称之为“好”。然后我首先在中间找到一个提交并对其进行测试。如果它很好,那么我在这个和 master 之间的提交上创建一个分支,否则,我在一个低于所选中间分支的提交上创建一个分支。这是迭代完成的,基本上是二进制排序。这意味着我检查的提交更少,并且我比 bisect 有更好的控制。通常我使用 gitk 来检查每个分支。另一个好处是,如果你找到了一些东西,你可以在一个单独的分支上工作,而不会影响其他分支。例如

Master Commit
.
. 
.
Test Commit  <---- This one is good, so keep selecting commits above until you fail
.
.
.
Middle Commit  <--- Create branch and checkout. This one is good, so go above
.
.
.
Good Commit
于 2012-11-26T22:12:50.257 回答