When I use Gitlens in VScode, I cannot find an option to compare commits on a file when they are not consecutive. If I use 'open changes' on a certain commit in the 'File History' panel, it always compares that version of the file with the previous one. Is there a way to choose to compare one revision of the file (and not necessarily the latest revision) with another revision of my choosing of that file?
To compare any two commits in your branch, use the Ctrl key to select the two commits that you want to compare. Then right-click one of them and select Compare Commits. Similar to Commit Details, you can use the Open in New Tab button to open the comparison on a different tab or maximize it on the screen.
Tip: You can diff any two files by first right clicking on a file in the Explorer or OPEN EDITORS list and selecting Select for Compare and then right-click on the second file to compare with and select Compare with 'file_name_you_chose'.
To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..
When you have repository open in Visual Studio code, you can execute the command Git: View History (git log) from the command Plate. This will open the Git History Window with all change logs for the repository. You can then select individual commits for detailed change logs for each of them.
You can compare two nonconsecutive commits via the following steps (assuming you have the Gitlens extension installed):
You will see that under the "Search & Compare" menu, your two different commits are compared.
edit note: you might not see a Gitlens tab anymore as it was (optionally) merged with the Source Control tab, in version 11.2.1.
gitlens:compare references
Then, in the right side bar, find SEARCH & COMPARE
You will find the two commits' diff details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With