@@ -3,7 +3,7 @@ git-bisect(1)
33
44NAME
55----
6- git-bisect - Find by binary search the change that introduced a bug
6+ git-bisect - Use binary search to find the commit that introduced a bug
77
88
99SYNOPSIS
@@ -16,7 +16,6 @@ DESCRIPTION
1616The command takes various subcommands, and different options depending
1717on the subcommand:
1818
19- git bisect help
2019 git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
2120 git bisect bad [<rev>]
2221 git bisect good [<rev>...]
@@ -26,58 +25,71 @@ on the subcommand:
2625 git bisect replay <logfile>
2726 git bisect log
2827 git bisect run <cmd>...
28+ git bisect help
2929
30- This command uses 'git rev-list --bisect' to help drive the
31- binary search process to find which change introduced a bug, given an
32- old "good" commit object name and a later "bad" commit object name.
30+ This command uses a binary search algorithm to find which commit in
31+ your project's history introduced a bug. You use it by first telling
32+ it a "bad" commit that is known to contain the bug, and a "good"
33+ commit that is known to be before the bug was introduced. Then `git
34+ bisect` picks a commit between those two endpoints and asks you
35+ whether the selected commit is "good" or "bad". It continues narrowing
36+ down the range until it finds the exact commit that introduced the
37+ change.
3338
3439Basic bisect commands: start, bad, good
3540~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3641
37- Using the Linux kernel tree as an example, basic use of the bisect
38- command is as follows:
42+ As an example, suppose you are trying to find the commit that broke a
43+ feature that was known to work in version `v2.6.13-rc2` of your
44+ project. You start a bisect session as follows:
3945
4046------------------------------------------------
4147$ git bisect start
4248$ git bisect bad # Current version is bad
43- $ git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
44- # tested that was good
49+ $ git bisect good v2.6.13-rc2 # v2.6.13-rc2 is known to be good
50+ ------------------------------------------------
51+
52+ Once you have specified at least one bad and one good commit, `git
53+ bisect` selects a commit in the middle of that range of history,
54+ checks it out, and outputs something similar to the following:
55+
56+ ------------------------------------------------
57+ Bisecting: 675 revisions left to test after this (roughly 10 steps)
4558------------------------------------------------
4659
47- When you have specified at least one bad and one good version, the
48- command bisects the revision tree and outputs something similar to
49- the following:
60+ You should now compile the checked-out version and test it. If that
61+ version works correctly, type
5062
5163------------------------------------------------
52- Bisecting: 675 revisions left to test after this
64+ $ git bisect good
5365------------------------------------------------
5466
55- The state in the middle of the set of revisions is then checked out.
56- You would now compile that kernel and boot it. If the booted kernel
57- works correctly, you would then issue the following command:
67+ If that version is broken, type
5868
5969------------------------------------------------
60- $ git bisect good # this one is good
70+ $ git bisect bad
6171------------------------------------------------
6272
63- The output of this command would be something similar to the following:
73+ Then `git bisect` will respond with something like
6474
6575------------------------------------------------
66- Bisecting: 337 revisions left to test after this
76+ Bisecting: 337 revisions left to test after this (roughly 9 steps)
6777------------------------------------------------
6878
69- You keep repeating this process, compiling the tree, testing it, and
70- depending on whether it is good or bad issuing the command "git bisect good"
71- or "git bisect bad" to ask for the next bisection.
79+ Keep repeating the process: compile the tree, test it, and depending
80+ on whether it is good or bad run `git bisect good` or `git bisect bad`
81+ to ask for the next commit that needs testing.
82+
83+ Eventually there will be no more revisions left to inspect, and the
84+ command will print out a description of the first bad commit. The
85+ reference `refs/bisect/bad` will be left pointing at that commit.
7286
73- Eventually there will be no more revisions left to bisect, and you
74- will have been left with the first bad kernel revision in "refs/bisect/bad".
7587
7688Bisect reset
7789~~~~~~~~~~~~
7890
7991After a bisect session, to clean up the bisection state and return to
80- the original HEAD (i.e., to quit bisecting) , issue the following command:
92+ the original HEAD, issue the following command:
8193
8294------------------------------------------------
8395$ git bisect reset
@@ -94,9 +106,10 @@ instead:
94106$ git bisect reset <commit>
95107------------------------------------------------
96108
97- For example, `git bisect reset HEAD` will leave you on the current
98- bisection commit and avoid switching commits at all, while `git bisect
99- reset bisect/bad` will check out the first bad revision.
109+ For example, `git bisect reset bisect/bad` will check out the first
110+ bad revision, while `git bisect reset HEAD` will leave you on the
111+ current bisection commit and avoid switching commits at all.
112+
100113
101114Bisect visualize
102115~~~~~~~~~~~~~~~~
@@ -141,17 +154,17 @@ $ git bisect replay that-file
141154Avoiding testing a commit
142155~~~~~~~~~~~~~~~~~~~~~~~~~
143156
144- If, in the middle of a bisect session, you know that the next suggested
145- revision is not a good one to test (e.g. the change the commit
146- introduces is known not to work in your environment and you know it
147- does not have anything to do with the bug you are chasing), you may
148- want to find a nearby commit and try that instead.
157+ If, in the middle of a bisect session, you know that the suggested
158+ revision is not a good one to test (e.g. it fails to build and you
159+ know that the failure does not have anything to do with the bug you
160+ are chasing), you can manually select a nearby commit and test that
161+ one instead.
149162
150163For example:
151164
152165------------
153166$ git bisect good/bad # previous round was good or bad.
154- Bisecting: 337 revisions left to test after this
167+ Bisecting: 337 revisions left to test after this (roughly 9 steps)
155168$ git bisect visualize # oops, that is uninteresting.
156169$ git reset --hard HEAD~3 # try 3 revisions before what
157170 # was suggested
@@ -163,18 +176,19 @@ the revision as good or bad in the usual manner.
163176Bisect skip
164177~~~~~~~~~~~~
165178
166- Instead of choosing by yourself a nearby commit, you can ask Git
167- to do it for you by issuing the command:
179+ Instead of choosing a nearby commit by yourself , you can ask Git to do
180+ it for you by issuing the command:
168181
169182------------
170183$ git bisect skip # Current version cannot be tested
171184------------
172185
173- But Git may eventually be unable to tell the first bad commit among
174- a bad commit and one or more skipped commits.
186+ However, if you skip a commit adjacent to the one you are looking for,
187+ Git will be unable to tell exactly which of those commits was the
188+ first bad one.
175189
176- You can even skip a range of commits, instead of just one commit,
177- using the "'<commit1>'..'<commit2>'" notation. For example:
190+ You can also skip a range of commits, instead of just one commit,
191+ using range notation. For example:
178192
179193------------
180194$ git bisect skip v2.5..v2.6
@@ -190,8 +204,8 @@ would issue the command:
190204$ git bisect skip v2.5 v2.5..v2.6
191205------------
192206
193- This tells the bisect process that the commits between `v2.5` included
194- and `v2.6` included should be skipped.
207+ This tells the bisect process that the commits between `v2.5` and
208+ `v2.6` (inclusive) should be skipped.
195209
196210
197211Cutting down bisection by giving more parameters to bisect start
@@ -225,14 +239,14 @@ or bad, you can bisect by issuing the command:
225239$ git bisect run my_script arguments
226240------------
227241
228- Note that the script (`my_script` in the above example) should
229- exit with code 0 if the current source code is good, and exit with a
230- code between 1 and 127 (inclusive), except 125, if the current
231- source code is bad.
242+ Note that the script (`my_script` in the above example) should exit
243+ with code 0 if the current source code is good/old , and exit with a
244+ code between 1 and 127 (inclusive), except 125, if the current source
245+ code is bad/new .
232246
233247Any other exit code will abort the bisect process. It should be noted
234- that a program that terminates via " exit(-1)" leaves $? = 255, (see the
235- exit(3) manual page), as the value is chopped with " & 0377" .
248+ that a program that terminates via ` exit(-1)` leaves $? = 255, (see the
249+ exit(3) manual page), as the value is chopped with ` & 0377` .
236250
237251The special exit code 125 should be used when the current source code
238252cannot be tested. If the script exits with this code, the current
@@ -241,7 +255,7 @@ as the highest sensible value to use for this purpose, because 126 and 127
241255are used by POSIX shells to signal specific error status (127 is for
242256command not found, 126 is for command found but not executable---these
243257details do not matter, as they are normal errors in the script, as far as
244- " bisect run" is concerned).
258+ ` bisect run` is concerned).
245259
246260You may often find that during a bisect session you want to have
247261temporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a
@@ -254,7 +268,7 @@ next revision to test, the script can apply the patch
254268before compiling, run the real test, and afterwards decide if the
255269revision (possibly with the needed patch) passed the test and then
256270rewind the tree to the pristine state. Finally the script should exit
257- with the status of the real test to let the " git bisect run" command loop
271+ with the status of the real test to let the ` git bisect run` command loop
258272determine the eventual outcome of the bisect session.
259273
260274OPTIONS
@@ -301,12 +315,12 @@ $ git bisect run ~/test.sh
301315$ git bisect reset # quit the bisect session
302316------------
303317+
304- Here we use a " test.sh" custom script. In this script, if " make"
318+ Here we use a ` test.sh` custom script. In this script, if ` make`
305319fails, we skip the current commit.
306- " check_test_case.sh" should " exit 0" if the test case passes,
307- and " exit 1" otherwise.
320+ ` check_test_case.sh` should ` exit 0` if the test case passes,
321+ and ` exit 1` otherwise.
308322+
309- It is safer if both " test.sh" and " check_test_case.sh" are
323+ It is safer if both ` test.sh` and ` check_test_case.sh` are
310324outside the repository to prevent interactions between the bisect,
311325make and test processes and the scripts.
312326
0 commit comments