-1

My question concerns when git bisect has found the first bad commit:

$ git bisect good
2060c40f6c3d3c057f9fdab31643599da375296b is the first bad commit  ❌
commit 2060c40f6c3d3c057f9fdab31643599da375296b
Author: ....
Date:   Tue Feb 16 11:15:52 2021 -0800

Now, ideally I want to proceed and identify the LAST GOOD COMMIT.

My question is:

(note: the steps of how I found the last good commit, manually, follow. It's not hard just tedious).

git fully knows 2060c40f6c3d3c057f9fdab31643599da375296b was preceded by 8993de6cc8bac3d5867e6b84fe30c52c9e604737 (see below). Is there a way to get that information quickly from git/ git bisect when it identifies the first bad commit, without having to search through commit history manually?

What I'd like to see

$ git bisect good
2060c40f6c3d3c057f9fdab31643599da375296b is the first bad commit
8993de6cc8bac3d5867e6b84fe30c52c9e604737 is the last good commit  MOCKUP

The details of how I found the last good commit:

git checkout <mybranch-before-git-bisect> then

git log

I am back all the way to the top, and can now look for the first bad commit

/2060c40f6c3d3c057f9fdab31643599da375296b

which gets me

commit 2060c40f6c3d3c057f9fdab31643599da375296b (037.secure.010.varsettings2jsontag, refs/bisect/bad) 
❌ 1ST BAD COMMIT
Author: ...
Date:   Tue Feb 16 11:15:52 2021 -0800

    037.secure.010.varsettings2jsontag fixed, added cssremovefilter ing for tests

commit 8993de6cc8bac3d5867e6b84fe30c52c9e604737 (refs/bisect/good-8993de6cc8bac3d5867e6b84fe30c52c9e604737)  
✅ LAST GOOD COMMIT
Author: ...
Date:   Mon Feb 15 22:29:42 2021 -0800

What doesn't work (but feels like it should)

  • git log right after bisect found the first bad commit wasn't useful
$ git log
commit 27f31fc8be6c6ef0ae493272364397c7b27f2550 (HEAD -> 059.ora.010.batch_usergroup_hang)
Author: ...
Date:   Tue Feb 9 21:36:43 2021 -0800 1️⃣

    "just a backup, use it sparingly on main codelines"

commit cdd80520ffd025a98629f3aa43a817ee4ebe96ab
Author: ...
Date:   Tue Jan 26 15:41:52 2021 -0800 2️⃣

    wip on generated/urls.py - not much so far

commit b7d05cf0df9a43b8ab3f36a81e618c8130905d87
Author: ...
Date:   Sun Nov 15 22:17:12 2020 -0800 3️⃣

i.e. if I git log after git bisect finds the first bad commit, I get 3 entries widely separated in time at 1️⃣ 2️⃣ 3️⃣. Numerous commits are missing, so this is useless.

I am on git version 2.23.0

JL Peyret
  • 10,917
  • 2
  • 54
  • 73
  • You can probably just use `2060c40f6c^` to refer to last good commit (being the parent of the first bad commit). No need for `bisect` to do anything special. – chepner Feb 18 '21 at 21:44
  • @chepner I'll take that as an answer, esp if you put that as `git show 2060c40f6c^ | head -1` which resolves to showing me the commit hash for its parent too. I know this must be obvious to anyone who knows git well, but... that's most assuredly not me. – JL Peyret Feb 18 '21 at 22:22

1 Answers1

1

The last good commit is just the parent of the first bad commit, which you can find by appending a ^ to the given commit hash:

$ git show 2060c40f6c^ | head -1
chepner
  • 497,756
  • 71
  • 530
  • 681