Is there a way to see git diff from origin/master using Visual Studio Code?

守給你的承諾、 提交于 2020-06-24 03:47:34

问题


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 Control button 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.

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?


回答1:


You can use an extension for this.

Two good options:

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).

You also can use Git History: 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.




回答2:


From Using Version Control in Visual Studio Code:

Add this to the Git configuration file, like ~/.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.




回答3:


I use GitLens extension as 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.




回答4:


From MSDN blog

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:




回答5:


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.



来源:https://stackoverflow.com/questions/44009551/is-there-a-way-to-see-git-diff-from-origin-master-using-visual-studio-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!