List commits between 2 commit hashes in git Ask Question

List commits between 2 commit hashes in git Ask Question

I know there has been very similar questions here, but they didn't solve my problem. Perhaps there's something I'm not understanding well.

This is a portion of the commit history of fitnesse (https://github.com/unclebob/fitnesse/):

* | | | | | | | | | | | | | | | fa86be8 Avoid possible issue when using CachingPage under heavy memory load.
|/ / / / / / / / / / / / / / /  
* | | | | | | | | | | | | | |   7b4a07a Merge pull request #256 from barredijkstra/fitnesse_issue_250
|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \  
| * | | | | | | | | | | | | | | ecf5891 Fixed test checking for OS specific exception message.
| * | | | | | | | | | | | | | | 082236e Added rendering of cause exceptions. Fix for unclebob/fitnesse#250
* | | | | | | | | | | | | | | |   a92b37f Merge pull request #243 from amolenaar/fix/243-hash-table-rendering

I want the list of commits between 2 commit hashes. In this particular case, I want the commits between ecf5891 and 7b4a07a, and I expect the result to be:

ecf5891
7b4a07a

Si far I've been using git rev-list commit_hash_from_here^..commit_hash_up_to_here and it has worked fine with linear history. However, in this case I get a lot more commits.

I've tried this and it works just as expected:

git log --since='<date ecf5891>' --until='<date 7b4a07a>'

(I've manually searched for those 2 dates).

One possible solution is to get the 2 dates and just do that, but I think there should be a better way.

Edit: 7b4a07a parents are ecf5891 and a92b37f. So far, the solutions work fine if I want to go from ecf5891 to 7b4a07a, but if I want to go from a92b37f to 7b4a07a I want to get:

7b4a07a
ecf5891
082236e
a92b37f

but I don't get a92b37f

ベストアンサー1

I think that you`re looking for --ancestry-path, in your case:

git rev-list --ancestry-path 7b4a07a..ecf5891

おすすめ記事