Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 462
Usman Avatar asked May 16 '17 19:05

Usman


People also ask

How do I see Git changes in Visual Studio code?

To help you focus on your Git repository, Visual Studio has a Git Repository window, which is a consolidated view of all the details in your repository, including local and remote branches and commit history. You can access this window directly from either Git or View on the menu bar or from the status bar.


2 Answers

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: Open Changes 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.

like image 138
Luís Henrique Faria Avatar answered Sep 20 '22 22:09

Luís Henrique Faria


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.

like image 27
bilabila Avatar answered Sep 16 '22 22:09

bilabila