How to see diff of each commit with Visual Studio Code?

22,289

Solution 1

Yes, it has built in git integration. Please refer to this tutorial. There are also plethora of extensions, like Git History and Git Project Manager

Git History extension result

Solution 2

  1. Install the GitLens extension (or it's already installed by default)
  2. Go to the GitLens tab in the sidebar
  3. Find the row 'Search Commits'
  4. Enter the commit SHA

You'll see all files that were changed in that commit.

click to see photo!

Solution 3

On Windows or Mac:

Ctrl + Shift + G

Then click on the "M" (short for Modified) next to the file that you wish to view diffing on.

Share:
22,289

Related videos on Youtube

Evanss
Author by

Evanss

Updated on September 18, 2022

Comments

  • Evanss
    Evanss almost 2 years

    I've been trying to move over to Visual Studio Code from WebStorm but WebStorm still has this one killer feature that I can't see how to do in Visual Studio Code.

    I can quickly pull up a list of my commits and then diff any one of them:

    enter image description here

    enter image description here

    Please tell me Visual Studio Code has a way of doing this?

    • Daniel B
      Daniel B almost 7 years
      Are you referring to Visual Studio 2015/2017 or Visual Studio Code?
    • Evanss
      Evanss almost 7 years
      Its Visual Studio Code.
  • Evanss
    Evanss over 6 years
    Its similar but I cant see a way of diffing by a commit rather than by a file.
  • igrinis
    igrinis over 6 years
    After you install Git History extension, you will get this ability. Command-Shit-P, select Git: View History (git log). You will see all the commits, much like in your first picture. Then you can select the (commited) version you want to compare to.
  • Jean Paul
    Jean Paul over 3 years
    Thanks for the suggestion. I don't think GitLens is installed by default but it is now integrated to the main source control tab.
  • Milan
    Milan over 3 years
    Nothing happens after pressing Ctrl + Shift + G!
  • ihodonald
    ihodonald over 3 years
    @Milan This still works for me on both Windows and Mac.
  • Milan
    Milan over 3 years
    Oh, I have been trying in Linux (Ubuntu 18.04). So, I guess there would be a different command for Linux. Thanks for confirming for Windows & Mac though :)
  • ihodonald
    ihodonald over 3 years
    @Milan Let me know so I can update the answer.
  • Milan
    Milan over 3 years
    As of now, I don't know the equivalent command for Ctrl + Shift + G in Ubuntu. But as soon as I do, I would comment here. Thank you!
  • Michael Fulton
    Michael Fulton over 2 years
    You should summarize the content of those links in your answer to answer the question more specifically.
  • Michael Fulton
    Michael Fulton over 2 years
    This should be the accepted answer