3

I know that you can view a diff from git with git log -p, and you can also provide multiple commits to view their diffs.

Is there any way to view the CUMULATIVE diff of multiple commits, all at once?

Note that I don't just want to see the diff BETWEEN two commits, I want the diff introduced by EACH commit to be shown in a single, unified diff -- as if they had been applied sequentially and I did a git log -p A..B -- but A and B are not linear in history.

The closest that I can manage is to do git merge-base of all of the relevant commits, create a new branch, and cherry-pick each commit so they are linear.

Zach Riggle
  • 2,975
  • 19
  • 26
  • 1
    Does this answer your question ? https://stackoverflow.com/q/3368590/6309111 – Dev-vruper Feb 11 '21 at 19:17
  • 1
    Are those multiple commits sequential commits in a branch or random? – phd Feb 11 '21 at 19:30
  • 1
    Does this answer your question? [Show diff between commits](https://stackoverflow.com/questions/3368590/show-diff-between-commits) – SwissCodeMen Feb 11 '21 at 22:10
  • 1
    No, this does not answer the question. The linked question is to show a diff BETWEEN two commits. I want to show the diff of BOTH commits in a unified patch. – Zach Riggle Feb 12 '21 at 10:59
  • Agreed that this is not a dupe. Not sure there exists a better solution than your own (cherry-picking on a dedicated branch) since they're are not consecutive. I'm interested in an alternate answer too. – xhienne Feb 12 '21 at 16:08
  • After some research I was unable to find a better solution than your own (except maybe that I would personally use git rebase, but this is a matter of taste). Marking this question as a dupe of [this one](https://stackoverflow.com/q/38842588/7233423) which is exactly the same. – xhienne Feb 13 '21 at 19:22
  • Does this answer your question? [Get a cumulative git diffs for multiple non-consecutuve commits](https://stackoverflow.com/questions/38842588/get-a-cumulative-git-diffs-for-multiple-non-consecutuve-commits) – xhienne Feb 13 '21 at 19:22
  • Cherry-picking to a new branch certainly achieves the effect I'm looking for, but I was hoping to avoid that scenario since the commit ID / hash changes. – Zach Riggle Feb 15 '21 at 00:06

0 Answers0