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
Solution 2
- Install the GitLens extension (or it's already installed by default)
- Go to the GitLens tab in the sidebar
- Find the row 'Search Commits'
- Enter the commit SHA
You'll see all files that were changed in that commit.
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.
Related videos on Youtube
Author by
Evanss
Updated on September 18, 2022Comments
-
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:
Please tell me Visual Studio Code has a way of doing this?
-
Daniel B almost 7 yearsAre you referring to Visual Studio 2015/2017 or Visual Studio Code?
-
Evanss almost 7 yearsIts Visual Studio Code.
-
-
Evanss over 6 yearsIts similar but I cant see a way of diffing by a commit rather than by a file.
-
igrinis over 6 yearsAfter you install
Git History
extension, you will get this ability. Command-Shit-P, selectGit: 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 over 3 yearsThanks for the suggestion. I don't think GitLens is installed by default but it is now integrated to the main source control tab.
-
Milan over 3 yearsNothing happens after pressing
Ctrl + Shift + G
! -
ihodonald over 3 years@Milan This still works for me on both Windows and Mac.
-
Milan over 3 yearsOh, 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 over 3 years@Milan Let me know so I can update the answer.
-
Milan over 3 yearsAs 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 over 2 yearsYou should summarize the content of those links in your answer to answer the question more specifically.
-
Michael Fulton over 2 yearsThis should be the accepted answer