Skip to content

Commit 6b87ce2

Browse files
anderskgitster
authored andcommitted
bisect reset: Allow resetting to any commit, not just a branch
‘git bisect reset’ accepts an optional argument specifying a branch to check out after cleaning up the bisection state. This lets you specify an arbitrary commit. In particular, this provides a way to clean the bisection state without moving HEAD: ‘git bisect reset HEAD’. This may be useful if you are not interested in the state before you began a bisect, especially if checking out the old commit would be expensive and invalidate most of your compiled tree. Clarify the ‘git bisect reset’ documentation to explain this optional argument, which was previously mentioned only in the usage message. Signed-off-by: Anders Kaseorg <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78d553b commit 6b87ce2

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Documentation/git-bisect.txt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on the subcommand:
2020
git bisect bad [<rev>]
2121
git bisect good [<rev>...]
2222
git bisect skip [(<rev>|<range>)...]
23-
git bisect reset [<branch>]
23+
git bisect reset [<commit>]
2424
git bisect visualize
2525
git bisect replay <logfile>
2626
git bisect log
@@ -81,16 +81,27 @@ will have been left with the first bad kernel revision in "refs/bisect/bad".
8181
Bisect reset
8282
~~~~~~~~~~~~
8383

84-
To return to the original head after a bisect session, issue the
85-
following command:
84+
After a bisect session, to clean up the bisection state and return to
85+
the original HEAD, issue the following command:
8686

8787
------------------------------------------------
8888
$ git bisect reset
8989
------------------------------------------------
9090

91-
This resets the tree to the original branch instead of being on the
92-
bisection commit ("git bisect start" will also do that, as it resets
93-
the bisection state).
91+
By default, this will return your tree to the commit that was checked
92+
out before `git bisect start`. (A new `git bisect start` will also do
93+
that, as it cleans up the old bisection state.)
94+
95+
With an optional argument, you can return to a different commit
96+
instead:
97+
98+
------------------------------------------------
99+
$ git bisect reset <commit>
100+
------------------------------------------------
101+
102+
For example, `git bisect reset HEAD` will leave you on the current
103+
bisection commit and avoid switching commits at all, while `git bisect
104+
reset bisect/bad` will check out the first bad revision.
94105

95106
Bisect visualize
96107
~~~~~~~~~~~~~~~~

git-bisect.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ git bisect skip [(<rev>|<range>)...]
1313
mark <rev>... untestable revisions.
1414
git bisect next
1515
find next bisection to test and check it out.
16-
git bisect reset [<branch>]
17-
finish bisection search and go back to branch.
16+
git bisect reset [<commit>]
17+
finish bisection search and go back to commit.
1818
git bisect visualize
1919
show bisect status in gitk.
2020
git bisect replay <logfile>
@@ -311,8 +311,8 @@ bisect_reset() {
311311
}
312312
case "$#" in
313313
0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
314-
1) git show-ref --verify --quiet -- "refs/heads/$1" ||
315-
die "$1 does not seem to be a valid branch"
314+
1) git rev-parse --quiet --verify "$1^{commit}" > /dev/null ||
315+
die "'$1' is not a valid commit"
316316
branch="$1" ;;
317317
*)
318318
usage ;;

0 commit comments

Comments
 (0)