1

I have a very deep git history

0000001
0000002
0000003
0000004
...

I used git-bisect to find the hash of an old issue which returned 0000003. Turns out the solution may lie in one of the commits after this hash 0000002 or even more recent

I can use

git log 0000003

which will show the history of the project until that commit, but nothing after

0000003
0000004
...

I want to find the commits around / after 0000003 using only hashes - ie, I want to find 0000002 without manually scrolling all the history.

How is this done?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
myol
  • 8,857
  • 19
  • 82
  • 143

2 Answers2

1

You can try and look for the next few commits (the ones created after 00003)

git log --reverse --pretty=format:%H --ancestry-path 3...master | head -3

With 3 being the SHA1 of the commit 00003.

You have other techniques described in "How do I find the next commit in git?".
For instance:

git rev-list HEAD..3 | tail -3

This assume those next commits are accessible from master or HEAD.

In the case where you don't have a particular "destination" commit in mind, but instead want to see child commits that might be on any branch, you can use this command:

git rev-list --children --all | grep ^${COMMIT}
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

git bisect is a good option as well as you used it already.

You can use the HEAD~X

# set X to be the number of commits you want to start with
git log HEAD~X

# Range: between HEAD to the previous X commits
git log HEAD...HEAD~X

Read here about commit range.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167