git 如何比较 Visual Studio Code 中的不同分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42112526/
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:47:16  来源:igfitidea点击:

How to compare different branches in Visual Studio Code

gitvisual-studio-code

提问by Vitaly Menchikovsky

How do I compare different branches in Visual Studio Code 1.9?

如何比较 Visual Studio Code 1.9 中的不同分支?

Is it possible?

是否可以?

回答by Manish Menaria

2019 answer

2019 答案

Here is the step by step guide:

这是分步指南:

  1. Install the GitLensextension: GitLens
  2. The GitLensicon will show up in nav bar. Click on it.

    Git lens icon

  3. Click on compare

    Enter image description here

  4. Select branches to compare

    enter image description here

  5. Now you can see the difference. You can select any file for which you want to see the diff for.

    Enter image description here

  1. 安装GitLens扩展:GitLens
  2. GitLens图标将在导航栏中显示。点击它。

    Git 镜头图标

  3. 点击比较

    在此处输入图片说明

  4. 选择要比较的分支

    在此处输入图片说明

  5. 现在你可以看到区别了。您可以选择要查看其差异的任何文件。

    在此处输入图片说明

回答by ddsultan

I would recommend to use: Git Lens.

我建议使用:Git Lens

回答by Vitaly Menchikovsky

UPDATE

更新

Now it's available:

现在它可用:

https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory

https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory

Until now it isn't supported, but you can follow the thread for it: GitHub

到目前为止它不受支持,但您可以关注它的线程:GitHub

回答by prograhammer

Use the Git History Diffplugin for easy side-by-side branch diffing:

使用Git History Diff插件轻松进行并行分支比较:

https://marketplace.visualstudio.com/items?itemName=huizhou.githd

https://marketplace.visualstudio.com/items?itemName=huizhou.githd

Visit the link above and scroll down to the animated GIF image titled Diff Branch. You'll see you can easily pick any branch and do side-by-side comparison with the branch you are on! It is like getting a preview of what you will see in the GitHub Pull Request. For other Git stuff I prefer Visual Studio Code's built-in functionality or Git Lens as others have mentioned.

访问上面的链接并向下滚动到标题为Diff Branch的动画 GIF 图像。您会看到您可以轻松选择任何分支并与您所在的分支进行并排比较!这就像预览您将在 GitHub 拉取请求中看到的内容。对于其他 Git 内容,我更喜欢 Visual Studio Code 的内置功能或其他人提到的 Git Lens。

However, the above plugin is outstanding for doing branch diffing (i.e., for those doing a rebase Git flow and need to preview before a force push up to a GitHub PR).

然而,上面的插件在执行分支差异方面非常出色(即,对于那些执行 rebase Git 流程并且需要在强制推送到 GitHub PR 之前进行预览的人)。

回答by skryvets

It's now possible by using the githistoryextension.

现在可以使用githistory扩展。

Here's a small trick though: You can compare the latest commits from each branch and that would be the same as comparing two branches side by side or creating a PR.

不过,这里有一个小技巧:您可以比较每个分支的最新提交,这与并排比较两个分支或创建 PR 相同。

Here's how to do that using githistory extension:

下面是如何使用 githistory 扩展来做到这一点:

  1. Open githistory
  2. Pick the latest commit from your current branch by clicking on "Git Commit Icon"→ (Usually it should be latest commit it the list). From the opened dropdown menu click on "Select this commit".
  3. Pick the latest commit from the branch you want to compare to by clicking "Git Commit Icon".
  4. As a result, the dropdown should appear with a few options → Select the last option that says "Compare with SHA" and you'll see the diff.
  1. 打开 githistory
  2. 通过单击“Git Commit Icon”→(通常应该是最新的提交列表)从当前分支中选择最新的提交。从打开的下拉菜单中单击“选择此提交”。
  3. 通过单击“Git Commit Icon”从要比较的分支中选择最新的提交。
  4. 因此,下拉菜单应该出现一些选项 → 选择最后一个选项“与 SHA 比较”,您将看到差异。