48

I have tried:

git diff sha1 sha2

But the output isn't the best, is it possible to see the difference between 2 commits using gitk?

Blankman
  • 259,732
  • 324
  • 769
  • 1,199

4 Answers4

63

In windows at least it is perfectly possible :

enter image description here

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
9

Not sure if you actually want a diff or if you want the normal gitk representation but only for the commits leading from sha1 to sha2

In the later case you can provide all the normal revision parameters: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html

So you can do things like

gitk sha1..sha2

or if master got merged into the sha2 branch and you don't want to see the commits that come from master and sha1, is the first commit branched from master use

gitk master..sha2
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
  • Same works for tags. We tag all releases, and this way I can easily see all commit messages and related diffs between two released project versions. If you know of some other neat ways to achieve this, please let me know =) – curious_prism Oct 27 '16 at 05:20
3

Unfortunately, gitk doesn't support diff output in that way. :-( You can use git difftool though. It comes with support for a number of tools builtin. For instance, you could do git difftool -t kdiff3 sha1 sha2. It shows the file diffs one at a time. There was talk on the git list about supporting more than just one file at a time via a diff tool, but I'm not sure where that ended up. I haven't seen a patch implementing it yet.

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79
  • 1
    Does that mean `gitk` can't use an external difftool? btw, you can use `git difftool -d sha1 sha2` to view directory differences now. – shengy Dec 22 '12 at 15:11
  • No, I don't believe so. :-( – John Szakmeister Dec 22 '12 at 15:35
  • I found that `gitk` supports `external diff` now, but it could only use the difftool to diff one file a time. And I'm sure that `git` now supports directory diff using the `git difftool -d sha1 sha2` command, My git's version is `1.8.0` and I believe that this feature was implemented in version `1.7.11` or some other earlier versions. – shengy Dec 22 '12 at 15:53
2

No, but you can do it using meld:

git checkout sha1
git reset sha2
git diftool --tool=meld

The trick is, by checking out sha1 and then resetting to sha2, you are making all the differences between them appear to be uncommitted changes. Then meld can use its ability to view uncommited changes, to do a diff of all the files involved at the same time.

Benubird
  • 18,551
  • 27
  • 90
  • 141