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

Viewed 82429

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?

7 Answers

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.

Compare local file changes to master

The accepted answer is good if you want to compare a single file from HEAD to some commit. On the other hand, if you need to diff all your files with another branch, Git Lens also provide solution for that: Go to source control tab on the side(1) > click on BRANCHES(2) > right click on the desired branch (like dev - 3)

enter image description here

Now, a menu will open, choose compare with HEAD

enter image description here

  • You could also do the same with commits, if in phase (2) you'll choose COMMITS instead.
  • You could also use cmnd+shift_p or ctrl+shift+p and type GitLens: Compare HEAD with, and then choose the specific wanted commit/branch.

I am using vscode with GitLens
The most convenient way to see diff from origin/$branch is to use git merge tool.
For example if I want to compare local and remote develop branch I will use the following command

git merge --no-commit --no-ff origin/develop

And the most exiting thing is that I can see all the changes in all the files from the gitlents extension tab and side by side and in case I don't want to merge there is a command

git merge --abort

Hope it helps someone!

Related