Skip to contentSkip to conversation

command to show diff of a commit

DISCUSSION Robert Watson 4 participants 6 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

Hi,

I am wondering what is the best way to show the change introduced by a commit. In the other words, is there a better way to do this:

git-diff b163512d4eb36ee946908b682c7863658c5a8db4^ b163512d4eb36ee946908b682c7863658c5a8db4

Thanks.
Robertoo

#1 lore raw

Dear diary, on Thu, Sep 22, 2005 at 11:58:32AM CEST, I got a letter where Robert Watson <[email protected]> told me that...

Quoted 1 line

Hi,

Hi,

Quoted 5 lines

I am wondering what is the best way to show the change introduced by a commit. In the other words, is there a better way to do this:

git-diff b163512d4eb36ee946908b682c7863658c5a8db4^ b163512d4eb36ee946908b682c7863658c5a8db4

with Cogito, you would say

	cg-diff -p -r b163512d4eb36ee946908b682c7863658c5a8db4

to see the diff against its parent. (You should still choose the parent manually in case of merge commits.)

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.
#2 lore raw
Quoted 12 lines · Petr Baudis

Dear diary, on Thu, Sep 22, 2005 at 11:58:32AM CEST, I got a letter where Robert Watson <[email protected]> told me that...

Quoted 1 line

Hi,

Hi,

Quoted 5 lines

I am wondering what is the best way to show the change introduced by a commit. In the other words, is there a better way to do this:

git-diff b163512d4eb36ee946908b682c7863658c5a8db4^ b163512d4eb36ee946908b682c7863658c5a8db4

Quoted 7 lines

with Cogito, you would say

        cg-diff -p -r b163512d4eb36ee946908b682c7863658c5a8db4

to see the diff against its parent. (You should still choose the parent manually in case of merge commits.)

Thanks, it is nice to know that cogito can go it. But can I achieve the same with git-core only?

Thanks,
Robertoo

#3 lore raw
Quoted 11 lines · Robert Watson
Quoted 7 lines · Petr Baudis

Dear diary, on Thu, Sep 22, 2005 at 11:58:32AM CEST, I got a letter

Quoted 5 lines

I am wondering what is the best way to show the change introduced by a commit. In the other words, is there a better way to do this:

git-diff b163512d4eb36ee946908b682c7863658c5a8db4^ b163512d4eb36ee946908b682c7863658c5a8db4

Thanks, it is nice to know that cogito can go it. But can I achieve the same with git-core only?

I suppose this is slightly shorter:

git-whatchanged --max-count=1 -p b163512d4eb36ee946908b682c7863658c5a8db4

skimo

#4 lore raw
In reply to Robert Watson
Quoted 6 lines · Robert Watson

I am wondering what is the best way to show the change introduced by a commit. In the other words, is there a better way to do this:

git-diff b163512d4eb36ee946908b682c7863658c5a8db4^ b163512d4eb36ee946908b682c7863658c5a8db4

Oh, absolutely.

Do

	git-diff-tree -p --pretty b163512d4eb36ee946908b682c7863658c5a8db4

and you're done.

If you _just_ want the diff (and not the message), skip the "--pretty".

Linus

#5 lore raw
Quoted 14 lines · Linus Torvalds
Quoted 6 lines · Robert Watson

I am wondering what is the best way to show the change introduced by a commit. In the other words, is there a better way to do this:

git-diff b163512d4eb36ee946908b682c7863658c5a8db4^ b163512d4eb36ee946908b682c7863658c5a8db4

Oh, absolutely.

Do

Quoted 8 lines
        git-diff-tree -p --pretty b163512d4eb36ee946908b682c7863658c5a8db4

and you're done.

If you _just_ want the diff (and not the message), skip the "--pretty".

Linus

Many thanks. I know there must be a way to do this.

Here is a patch to make the document a bit clearer.

Regards,
Robertoo

Documentation/git-diff-tree.txt +0 -1
@@ -9,12 +9,15 @@ git-diff-tree - Compares the content and
 
 SYNOPSIS
 --------
-'git-diff-tree' [--stdin] [-m] [-s] [-v] [--pretty] [-t] [<common

diff options>] <tree-ish> <tree-ish> [<path>...] +'git-diff-tree' [--stdin] [-m] [-s] [-v] [--pretty] [-t] [<common diff options>] <tree-ish> [<tree-ish>] [<path>...]

DESCRIPTION
-----------
Compares the content and mode of the blobs found via two tree objects.

+If there is only one <tree-ish> given, the commit is compared with its parents +(see --stdin below).
+
Note that "git-diff-tree" can use the tree encapsulated in a commit object.

OPTIONS