git 如何区分 GitHub 中的两个分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43552274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:56:41  来源:igfitidea点击:

How can I diff two branches in GitHub?

gitgithubgit-branch

提问by Lost

I am just wondering if there is a way to simply diff two branches in GitHub? I know GitHub has capacity to do it because when we do code-reviews it does list out all the diffs nicely. I was just wondering if there is a way to do it without any code review to compare say Branch to Branch or Commit to Commit? So that when I push something to my remote branch and I want to see how my diffs are going to look like BEFORE it create a PR then it can be very helpful.

我只是想知道是否有一种方法可以简单地比较 GitHub 中的两个分支?我知道 GitHub 有能力做到这一点,因为当我们进行代码时,它确实会很好地列出所有差异。我只是想知道是否有一种方法可以在没有任何代码的情况下将分支与分支或承诺提交进行比较?因此,当我将某些内容推送到我的远程分支时,我想看看我的差异在创建 PR 之前会是什么样子,那么它会非常有帮助。

I can always be in console and do git diff but that is really not as nice and visually clear as how it shows up in web UI of GitHub. Any ideas?

我总是可以在控制台中执行 git diff ,但这确实不像它在 GitHub 的 Web UI 中显示的那样美观和直观。有任何想法吗?

采纳答案by Ari M.

Use the comparefeature to accomplish this.

使用比较功能来完成此操作。

回答by tkausl

If you are on any branch other than master you should see a link to compare:

如果您在 master 以外的任何分支上,您应该看到一个链接来比较

Compare 1

比较 1

Click it and you should get redirected to the compare-tool where you can select branches or commits to compare

单击它,您应该被重定向到比较工具,您可以在其中选择要比较的分支或提交

Compare 2

比较 2