如何比较两个提交的内容?

How to compare content of two commits?

有人 git push --force 和我发生合并冲突。

比较本地和远程分支我可以看到 (1) 最后两个提交被 (2) 只有一个替换。并添加了新的 242ab72 提交。

现在我想分析提交 5892f6b6a53778 提交有何不同。

有类似下一个命令的吗?

diff -ruBN $(git show 6a53778) $(git show 5892f6b)

注意:我不想看到 6a537785892f6b 之间的区别。
我想比较一下这两个提交的内容有何不同。

我找到这个 good answer:

diff -ruBN <(git show 6a53778) <(git show 5892f6b)

UPD
我还发现 this:

[alias]
        intercommit = !sh -c 'interdiff <(git show ) <(git show ) | less -FRS' 

通知
interdiff 可能会导致错误:

interdiff: Error applying patch1 to reconstructed file

这是因为 interdiff doesn't have the advantage of being able to look at the files that are to be modified.

Git 2.19 引入了一个新命令,git range-diff 执行此操作:

git-range-diff - Compare two commit ranges (e.g. two versions of a branch)

查看详情here

git range-diff 94516fd0...a22765c4

的例子