1

How can I list the commits of a specific merge-commit 845884.

Here, for instance, I only want commits 1, 2, 3 and only them

*   845884... Merged branch xxxx
|\
| * 68daa7... commit 3
* | a58ec2... commit from master
| |
| * 87da50... commit 2
| |
| * 5e62f9... commit 1
* | 766e1b... commit from master
|/
* 4b8f227
Stef
  • 3,691
  • 6
  • 43
  • 58
  • 2
    you could say `git log a58ec2..68daa7` that will only list those revisions.... but that is so simple that I wonder if you are asking for a concept deeper than that? – eftshift0 Oct 05 '20 at 16:08
  • Thanks, but it doesn't work... an interval will give all commits... – Stef Oct 05 '20 at 16:27
  • So, if you are looking to output only commits 1,2, and 3, does something like this work for you? `git log $(git log -1 --merges --pretty=format:%P | awk '{print $(NF)}')...$(git merge-base --octopus $(git log -1 --merges --pretty=format:%P)) --graph --pretty=oneline --abbrev-commit` – mnestorov Oct 05 '20 at 17:21
  • Nice, but doesn't seem to work, Get all – Stef Oct 05 '20 at 17:37
  • @Stef, with that command, which commits are missing? – mnestorov Oct 05 '20 at 17:42
  • I get all the commits even them below 4b8f227 – Stef Oct 05 '20 at 17:46
  • 1
    Huh, that's weird, I tried to re-create the history you've shown and it works. What happens if you add the `--boundary` option at the end? – mnestorov Oct 05 '20 at 17:48
  • Sorry, I still have the commits of the master... :( – Stef Oct 05 '20 at 17:53
  • 2
    Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/222556/discussion-between-mnestorov-and-stef). – mnestorov Oct 05 '20 at 17:57

1 Answers1

2

Try :

git log --oneline --graph <commitId>^..<commitId>

If you want to exclude the merge commit itself :

git log --oneline --graph <commitId>^..<commitId>^2
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • 1
    re-reading the comments, this answer is exactly the same as @eftshift0's. I think the OP didn't try to type it, because it would have given him what he wanted. – LeGEC Oct 05 '20 at 20:04
  • 1
    Yes, my mistake I took the merge-commit as first item... Thanks you to @mnestorov too... – Stef Oct 05 '20 at 20:48