计算不同分支上文件的差异。 GitHub 服务器与 GIT (cli)

Computing diff of files on different branches. GitHub Server vs GIT (cli)

假设您在 git 存储库中有两个 git 分支:

  1. 分支一(比方说@commit abc111)
  2. 分支二(比方说@commit xyz222)

在存储库中,我可以通过从终端执行 git diff 命令来验证两个位置的单个文件是否相同:

这可以通过以下语法使用 git 命令行完成:

git diff abc111 xyz222 -- foo.txt

我遇到的问题是当我尝试使用 GitHub 服务器的(比较或 PR)差异功能比较这两个分支(在它们各自的提交 ID 位置)时。

我可以去下面URL:

http://<our-v2.9.0-github-appliance-url>/<repo>/abc111...xyz222

...及其在文件中的显示差异 foo.txt

知道为什么 git 集线器服务器的 compare/pr 功能显示 'diff' 的文件,而本不应该有任何文件吗?

感谢 assistance/pointers。

我认为这是因为 <commit>..<commit>git diff <commit> <commit> is)和 <commit>...<commit> 不同。

来自 git-diff docs...

   git diff [--options] <commit> <commit> [--] [<path>...]
       This is to view the changes between two arbitrary <commit>.

   git diff [--options] <commit>..<commit> [--] [<path>...]
       This is synonymous to the previous form. If <commit> on one side is omitted, it
       will have the same effect as using HEAD instead.

   git diff [--options] <commit>...<commit> [--] [<path>...]
       This form is to view the changes on the branch containing and up to the second
       <commit>, starting at a common ancestor of both <commit>. "git diff A...B" is
       equivalent to "git diff $(git-merge-base A B) B". You can omit any one of
       <commit>, which has the same effect as using HEAD instead.

您在命令行中执行 <commit>..<commit>,在 URL 中执行 <commit>...<commit>