gitgit-bisect

git bisect and finding last good commit - am I missing something?


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
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


Solution

  • 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