Reputation: 321
I have a problem , I need to see difference of first and third commit in git, but I can see diff of any commit and previous to it.
Upvotes: 5
Views: 1100
Reputation: 923
There is a great GUI tool that will allow you to compare any 2 commits called Git Extensions. Info/download can be found here: https://gitextensions.github.io/.
All you have to do is select the repository you want to look at and Git Extensions will show you the entire commit history across all branches that you are tracking. Just click on the earlier commit, then use CTRL+click on the commit you want to compare to, then in the window at the bottom left of the screen select the "Diff" tab and you can see all diffs across all files in the Repository.
Image is included for reference: Git Extensions GUI example
This is a little more versatile than Git Bash to look at individual file diffs in one window and allow you to switch between files easily. It is available on Windows and Linux though I have only used it on windows.
Upvotes: 5
Reputation: 1381
git diff [--options] <commit> <commit> [--] [<path>…] This is to view the changes between two arbitrary <commit>.
You can get the commit hashes of the 1st and 3rd commit from the log for instance, or you can run it like this (with the relative path to the commits):
git diff HEAD~1 HEAD~3
Upvotes: 6