190

I'm doing a non-automated git bisect via command line. All is going well until I accidentally hit return on the wrong line in my command history, and rather than running the test, I run 'git bisect good' (or bad). Oops - I don't yet know if this commit should be marked good or bad, yet that's what I've done.

Can I undo the 'git bisect good' command, or make git forget the result of it, and go back and run the test for that commit?

Graham Perks
  • 22,303
  • 8
  • 57
  • 81

2 Answers2

243

From the git-bisect documentation:

Bisect log and bisect replay

After having marked revisions as good or bad, issue the following command to show what has been done so far:

$ git bisect log

If you discover that you made a mistake in specifying the status of a revision, you can save the output of this command to a file, edit it to remove the incorrect entries, and then issue the following commands to return to a corrected state:

$ git bisect reset
$ git bisect replay that-file
Ruslan
  • 16,681
  • 5
  • 61
  • 121
manojlds
  • 275,671
  • 58
  • 453
  • 409
  • Too complicated, too many it-dependses. What command or sequence of commands, taking NO parameters depending on the current repository state (i.e. "that-file"), will GUARANTEEDLY reset the repository to the state just before the erroneous command? – Szczepan Hołyszewski Dec 01 '21 at 10:42
  • @SzczepanHołyszewski This literally took 25 seconds from I read it to me being exactly where I was before I mistakenly issued a `git bisect good` too many. There are no "it depends" bits here. Just literally do it. It is not complicated. `git bisect log > f; vim f; git bisect reset; git bisect replay f;` – oligofren Mar 01 '22 at 13:51
119

You can output a record of what was done using

$ git bisect log > bisect.log

Open that file in an editor and edit/remove the faulty line. Then you can replay it with

$ git bisect replay bisect.log

This is documented in git help bisect.

Benjamin Bannier
  • 50,375
  • 11
  • 61
  • 80