tags:

views:

123

answers:

2

In $VCS I make heavy use of $VCS diff -c $N to see only the changes introduced in revision $N (ie, diff -r $N..$N+1).

How can I do the same thing with git?

+4  A: 
git diff SHA1_COMMIT^ SHA1_COMMIT

With SHA1_COMMIT being the SHA1 of the commit you want to inspect.
That "git diff" will compare:

  • the version before the commit referenced by that SHA1 and
  • the commit referenced by said SHA1.

As mentioned in the source code of the builtin-diff.c, the syntax parsed is:

static const char builtin_diff_usage[] =
"git diff <options> <rev>{0,2} -- <path>*"
VonC
Technically, they only need to be "commitish" objects. So, you can also say "git diff HEAD~2 HEAD" or "git diff HEAD origin/master".
Pat Notz
@Pat, you are right. My answer was made for the specifics of the question ("see only the changes introduced in revision $N"), but you can indeed specify any two commits.
VonC
+5  A: 
# git show -p SHA1_COMMIT
Bombe
Good catch. +1. I always forgot about the git show
VonC
I usually prefer it because I only need to type (or paste) a single commit ID. :)
Bombe