有没有办法使用 Visual Studio Code 从 origin/master 查看 git diff ?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44009551/
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
Is there a way to see git diff from origin/master using Visual Studio Code?
提问by Usman
Using Visual Studio Code (version 1.11.2), I can see a side-by-side graphical diff of my current changes very easily by clicking the Source Controlbutton in the left panel. But once I commit those changes to my local repository, I am unable to find a way to see the same side-by-side diff from origin/master.
使用 Visual Studio Code(版本 1.11.2),我可以通过单击左侧面板中的Source Control按钮轻松查看当前更改的并排图形差异。但是一旦我将这些更改提交到我的本地存储库,我就无法找到一种方法来查看来自 origin/master 的相同并排差异。
In other words, is there a way to the spawn comparison tool of Visual Studio Code (version 1.11.2) to show me what I see when I do git diff origin/master
, but in the side-by-side graphical diff too?
换句话说,有没有办法让 Visual Studio Code(版本 1.11.2)的 spawn 比较工具向我展示我在做的时候看到的东西git diff origin/master
,但在并排的图形差异中呢?
回答by Luís Henrique Faria
You can use an extension for this.
您可以为此使用扩展程序。
Two good options:
两个不错的选择:
Gitlens:https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens
Gitlens:https ://marketplace.visualstudio.com/items ? itemName = eamodio.gitlens
With this one, you can use the >GitLens: Compare File with...
action to compare with any branch (local or remote).
有了这个,您可以使用该>GitLens: Compare File with...
操作与任何分支(本地或远程)进行比较。
You also can use Git History: https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory
您也可以使用Git 历史记录:https: //marketplace.visualstudio.com/items? itemName =donjayamanne.githistory
You can see the entire file history and compare with the current version with the >Git: View File History
action.
您可以查看整个文件历史记录并通过操作与当前版本进行比较>Git: View File History
。
回答by bilabila
From Using Version Control in Visual Studio Code:
从在 Visual Studio Code 中使用版本控制:
Add this to the Git configuration file, like ~/.gitconfig
:
将此添加到 Git 配置文件中,例如~/.gitconfig
:
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
When using git difftool HEAD HEAD^
, Git will ask if to use Visual Studio Code.
使用时git difftool HEAD HEAD^
,Git 会询问是否使用Visual Studio Code。
回答by mimo
I use GitLens extensionas well. Go to Source Control
tab, right click on file you want to compare with origin/master
(or other) branch. From the menu choose Open Changes with...
and pick a branch.
我也使用GitLens 扩展。转到Source Control
选项卡,右键单击要与origin/master
(或其他)分支进行比较的文件。从菜单中选择Open Changes with...
一个分支。
回答by Rahul
From MSDN blog
来自MSDN 博客
Viewing Diffs
查看差异
Our Git tooling supports viewing of Diffs within VS Code. Click the file in the Git view to display a side-by-side view. This allows you to compare your current file with a previous version of it:
我们的 Git 工具支持在 VS Code 中查看差异。单击 Git 视图中的文件以显示并排视图。这允许您将当前文件与它的先前版本进行比较:
回答by Johnny5
It doesn't use Visual Studio Code, but if you just want to see a quick summary of changes... just start a PR from the branch on GitHub.
它不使用 Visual Studio Code,但如果您只想查看更改的快速摘要……只需从 GitHub 上的分支启动 PR。