0

We have commits 1->2->3->4->5

Do see the diff since (and including) commit 3 we can do git diff 3~1.

This will show the collective diffs to the source tree from diff 3 including 3/4/5.

Question is - how can we see the diffs resulting from just 3 and 5 but not 4?

Commit 4 is a commit to a different part of the source. 3 and 5 are related and we only want to see the diff resulting from those commits.

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
  • 1
    `git checkout -b tmp 3;git cherry-pick 5` now you get 1->2->3->5'. You could also make it by `git rebase --onto 3 4 5`. – ElpieKay May 21 '16 at 16:14
  • You don't even need a branch name for this, just do it. `git checkout 3; git cherry-pick 5; git diff 3~;git checkout @{-1}` – jthill May 21 '16 at 17:14

1 Answers1

0

I don't think you can exclude specific commits in a range, but I think the key to your question is the point you make about Commit 4 being in a different part of the source tree.

If your directory tree structure allows it you can limit the diff to just those directories in the source tree that you are interested in.

git diff <commit3> <commit1> -- <path> <path> <path>

where the <path> arguments list out 1 or more top-level directories containing the files that you are interested in.

Also, see Exclude a directory from git diff for some shell-based mechanisms to exclude just a single directory.

Community
  • 1
  • 1
Rob
  • 1,472
  • 12
  • 24