Git 同一分支上两个不同文件的区别

Git diff between 2 different files on the same branch

我有 2 个不同的文件 foobar

每个都在同一分支上的 2 次不同提交中,分别使用 SHA1 SHA1-fooSHA1-bar。 我想查看这两个文件之间的差异。

我可以签出其中一个文件并复制它,但也许有更好的方法。

我发现它的工作方式与分支相同,参见 this SO thread

git diff SHA1-foo:/path/to/foo SHA1-bar:/path/to/bar

你可以这样做:

git diff branch1:file branch2:file