Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I "diff -c" with git?

Tags:

git

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?

like image 464
David Wolever Avatar asked Dec 10 '22 21:12

David Wolever


2 Answers

# git show -p SHA1_COMMIT
like image 81
Bombe Avatar answered Dec 17 '22 10:12

Bombe


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>*"
like image 42
VonC Avatar answered Dec 17 '22 08:12

VonC