Github 2 个分支的比较视图不正确?
Github Comparison View for 2 branches is incorrect?
当我在 master
和另一个分支 A
之间执行 Github comparison view 时,Github 似乎将 A
的 HEAD 版本与旧版本进行比较, master
.
的非头部版本
我调查了一下,据我所知,Github 是在将分支 A
与 master
的共同祖先进行比较。它实际上并没有将它与 master.HEAD
当前的内容进行比较。
有没有办法区分 master 的 HEAD 和 Github 中 Branch A
的 HEAD?
如果不是,为什么不呢?这似乎是每个开发人员都希望能够实现的功能。或者是否有一些我可能遗漏的应该完成的过程?我希望能够直接从这些差异之一创建 Pull Request。
编辑:这是一个显示问题的示例回购
https://github.com/bradparks/test_github_diff_view
- 我创建了一个包含单个文件的新存储库,README.md
- 我将此文件设置为包含一行
v100
。
- 然后我将 master 分支到一个新分支
A
,并将行更改为 `v200'
然后我将 master 分支中的值更改为 'v300',然后使用比较 link
比较 2 个分支
https://github.com/bradparks/test_github_diff_view/compare/A
我看到了以下意想不到的结果。为什么它不区分 v300
而不是 v100
?
Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?
Sept 2018: yes: GitHub now explicitly supports "Three-dot and two-dot Git diff comparisons". See an example here.
keisuke mentions a similar initiative on Bitbucket.
2015 年原答案:
否:如“GitHub compare view for current versions of branches”中所述,GitHub 仅支持三点 (...) 范围快捷方式规范。
即:
This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both.
"git diff A...B
" is equivalent to "git diff $(git-merge-base A B) B
".
You can omit any one of , which has the same effect as using HEAD instead.
official GitHub help 将此功能提到为:
The most common use of Compare is to compare branches, such as when you're starting a new Pull Request.
在那种情况下,PR 分支从 master 开始(或者无论如何应该在 master 之上重新建立基础),这意味着 master HEAD 是 master 和 PR 分支之间的基础。
但是当两个分支分叉后,比较的不再是HEADs
,而是一个共同祖先和一个HEAD:git diff $(git-merge-base master B) B
.
注意:即使您直接指定两个 SHA1,正如“Comparing commits”中明确记录的那样,仍然 会执行 git diff $(git-merge-base A B) B
.
那会不会直接在两个提交之间做差异。
Is there a way to diff the HEAD of master against the HEAD of Branch A
in Github?
[编辑:不,我错了。我设法有一个 URL 看起来它会做正确的事情并且页面上的差异看起来是正确的,但那是一个意外。如果您真的想了解更多,请查看此答案的历史记录。]
只是另一个想法。如果你想从你的工作和 master 分支的负责人之间的差异创建一个拉取请求(根据 o.p),那么你需要做的是首先将你自己的分支从 master 分支git rebase <master>
然后提出拉取请求。
但是您通常不需要这样做,Git 非常擅长合并,并且通常能够按照您的意愿将您的工作添加到 master 分支中,即使您不这样做'先变基。
当我在 master
和另一个分支 A
之间执行 Github comparison view 时,Github 似乎将 A
的 HEAD 版本与旧版本进行比较, master
.
我调查了一下,据我所知,Github 是在将分支 A
与 master
的共同祖先进行比较。它实际上并没有将它与 master.HEAD
当前的内容进行比较。
有没有办法区分 master 的 HEAD 和 Github 中 Branch A
的 HEAD?
如果不是,为什么不呢?这似乎是每个开发人员都希望能够实现的功能。或者是否有一些我可能遗漏的应该完成的过程?我希望能够直接从这些差异之一创建 Pull Request。
编辑:这是一个显示问题的示例回购
https://github.com/bradparks/test_github_diff_view
- 我创建了一个包含单个文件的新存储库,README.md
- 我将此文件设置为包含一行
v100
。 - 然后我将 master 分支到一个新分支
A
,并将行更改为 `v200' 然后我将 master 分支中的值更改为 'v300',然后使用比较 link
比较 2 个分支https://github.com/bradparks/test_github_diff_view/compare/A
我看到了以下意想不到的结果。为什么它不区分
v300
而不是v100
?
Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?
Sept 2018: yes: GitHub now explicitly supports "Three-dot and two-dot Git diff comparisons". See an example here.
keisuke mentions
2015 年原答案:
否:如“GitHub compare view for current versions of branches”中所述,GitHub 仅支持三点 (...) 范围快捷方式规范。
即:
This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both.
"
git diff A...B
" is equivalent to "git diff $(git-merge-base A B) B
".
You can omit any one of , which has the same effect as using HEAD instead.
official GitHub help 将此功能提到为:
The most common use of Compare is to compare branches, such as when you're starting a new Pull Request.
在那种情况下,PR 分支从 master 开始(或者无论如何应该在 master 之上重新建立基础),这意味着 master HEAD 是 master 和 PR 分支之间的基础。
但是当两个分支分叉后,比较的不再是HEADs
,而是一个共同祖先和一个HEAD:git diff $(git-merge-base master B) B
.
注意:即使您直接指定两个 SHA1,正如“Comparing commits”中明确记录的那样,仍然 会执行 git diff $(git-merge-base A B) B
.
那会不会直接在两个提交之间做差异。
Is there a way to diff the HEAD of master against the HEAD of Branch A in Github?
[编辑:不,我错了。我设法有一个 URL 看起来它会做正确的事情并且页面上的差异看起来是正确的,但那是一个意外。如果您真的想了解更多,请查看此答案的历史记录。]
只是另一个想法。如果你想从你的工作和 master 分支的负责人之间的差异创建一个拉取请求(根据 o.p),那么你需要做的是首先将你自己的分支从 master 分支git rebase <master>
然后提出拉取请求。
但是您通常不需要这样做,Git 非常擅长合并,并且通常能够按照您的意愿将您的工作添加到 master 分支中,即使您不这样做'先变基。