GitHub比较当前版本的分支机构的视图 [英] GitHub compare view for current versions of branches

查看:76
本文介绍了GitHub比较当前版本的分支机构的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用GitHub的比较视图来查看两个分支的当前版本之间的差异? (也就是说,要查看如果您执行 git diff< a-branch>< another-branch> ,您将得到的差异。)



我在这里做了一个小例子 。有两个分支:主和其他分支。如果我做 git diff master..other-branch ,这是diff:

  diff --git a / README.md b / README.md 
index 495cc9f..3d2c3a0 100644
--- a / README.md
+++ b / README .md
@@ -1 +1,3 @@
你好!
+
+这是对其他分支分支的提交。

您可以从该差异中看出主分支与其他分支 分支是增加了一个空行和一行文本,并且没有删除。



但是,如果我尝试使用GitHub比较视图( https://github.com/akenney/compare-view-test/compare/other-branch https://github.com/akenney/compare-view-test/compare /master...other-branch ),它显示了这个区别:

   - 这是对主分支。 
+你好!
+
+这是对其他分支分支的提交。

它将other-branch分支与旧版本的master分支进行比较,不与当前版本。即使我指定了要比较的特定提交( https:// github),也会发生同样的情况。 com / akenney / compare-view-test / compare / 8ed0d53 ... e4470ec ) - 它显示的差异不是这两个提交之间的差异。 gitHub只支持三点( ... )范围快捷方式规范。



git diff文档


git diff [--options] .. [ - ] [...]



这与以前的表单是同义的。如果在一侧被省略,
将与使用HEAD具有相同的效果。



git diff [--options] ... [ - ] [...]



这个表单是查看包含第二个分支的分支上的变化,从共同的祖先开始。 git diff A ... B相当于git diff $(git-merge-base A B)B。您可以省略其中的任何一个,这与使用HEAD具有相同的效果。



Is there a way to use GitHub's "compare view" to view the diff between the current versions of two branches? (That is, to view the same diff that you would get if you did git diff <a-branch> <another-branch>.)

I have made a small example here. There are two branches: "master" and "other-branch". If I do git diff master..other-branch, this is the diff:

diff --git a/README.md b/README.md
index 495cc9f..3d2c3a0 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
 Hello there!
+
+This is a commit to the "other-branch" branch.

You can see from that diff that the difference between the "master" branch and the "other-branch" branch is the addition of one blank line and one line of text, and there are no deletions.

However, if I try to use GitHub compare view (https://github.com/akenney/compare-view-test/compare/other-branch or https://github.com/akenney/compare-view-test/compare/master...other-branch), it shows this diff:

-This is a commit to the master branch.
+Hello there!
+
+This is a commit to the "other-branch" branch.

It is comparing the "other-branch" branch with an old version of the "master" branch, not with the current version. The same thing happens even if I specify the particular commits to compare (https://github.com/akenney/compare-view-test/compare/8ed0d53...e4470ec) - the diff that it's showing is not the diff between those two commits.

解决方案

GitHub only supports the triple dots (...) range shortcut specification.

From the git diff documentation:

git diff [--options] .. [--] […]

This is synonymous to the previous form. If on one side is omitted, it will have the same effect as using HEAD instead.

git diff [--options] ... [--] […]

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.

这篇关于GitHub比较当前版本的分支机构的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆