我git bisect
最近试图使用,但它只是没有用.树仍然是主人,我没有看到任何输出git bisect
.这是我尝试过的:
git bisect start
git bisect bad # no output, tried a couple of times
git bisect good # no output
git bisect reset #-> Already on 'master'
Run Code Online (Sandbox Code Playgroud)
我尝试了两个不同的回购.没工作.关于Ubuntu 9.10的git --version是1.6.3.3任何想法?
Way*_*rad 18
Git Bisect简介
"git bisect"起初可能有点令人困惑.一旦你理解它的作用,就会很容易.
"git bisect"的典型场景是:刚刚发现了一个bug.你想知道哪个rev引入了bug.您知道最新版本中存在该错误,但它是在之前的版本中引入的.您需要一种方法来确定是否存在该错误.这可以是自动测试,也可以是手动测试.
让我们开始吧.从您分支机构的最新版本开始,发出:
git bisect start
Run Code Online (Sandbox Code Playgroud)
然后告诉git当前版本已知不好:
git bisect bad
Run Code Online (Sandbox Code Playgroud)
现在我们需要找到一个好的转速.检查一个足够老的东西,没有错误.如果你认为32转前应该是好的,那么:
git checkout HEAD~32
Run Code Online (Sandbox Code Playgroud)
并运行您的测试,看看它是否有错误.如果它有bug,你需要尝试更老的转速(再次发出"git checkout HEAD~32").一旦你登陆没有错误的转速,那么:
git bisect good
Run Code Online (Sandbox Code Playgroud)
这告诉git当前版本是好的.Git会立即检查好转速和坏转速之间的转速; 你会看到输出,例如:
$ git bisect good
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[909ba8cd7698720d00b2d10738f6d970a8955be4] Added convenience delegators to Cache
Run Code Online (Sandbox Code Playgroud)
运行测试,并根据测试结果发出以下命令之一:
git bisect good # the test passed
git bisect bad # the test failed
git bisect skip # we can't run the test on this rev for some reason
(doesn't compile, etc.)
Git将继续改变到不同的转速,你会一直告诉它好,坏或跳过.当git终于弄清楚哪个rev开始了所有的麻烦,你会得到这样的东西:
b25ab3cee963f4738264c9c9b5a8d1a344a94623 is the first bad commit
commit b25ab3cee963f4738264c9c9b5a8d1a344a94623
Author: Wayne Conrad <wconrad@yagni.com>
Date: Fri Dec 25 18:20:54 2009 -0700
More tests and refactoring
:040000 040000 6ff7502d5828598af55c7517fd9626ba019b16aa 39f346cb5a289cdb0955fcbba552f40e704b7e65 M routecalc
Run Code Online (Sandbox Code Playgroud)
在第一次糟糕的提交中,您当前的转速将在那里.
运行git bisect"hand off"
如果您的测试是自动的,那么您可以让git完成所有工作.做你上面开始做的一切:
git bisect start
git bisect bad
git checkout HEAD~32 # or however far back it takes to find a good rev
git bisect good
Run Code Online (Sandbox Code Playgroud)
而现在为了魔术.您所需要的只是一个测试程序,它返回退出代码"0"表示成功,1表示(例如)表示失败.告诉git你的测试:
git bisect run tests/mytest.rb
Run Code Online (Sandbox Code Playgroud)
Git现在将运行测试,使用结果自动执行"git bisect good"或"git bisect bad".它将继续这样做,直到找到引入该bug的提交.你所要做的就是坐下来观看.
当你完成了
完成后,发出:
git bisect reset
Run Code Online (Sandbox Code Playgroud)
Git会把你带回到你开始的地方.