Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-diff-tree(1) |
| 2 | ================ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-diff-tree - Compares the content and mode of blobs found via two tree objects |
| 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 12 | 'git diff-tree' [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty] |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 13 | [-t] [-r] [-c | --cc] [--root] [<common diff options>] |
| 14 | <tree-ish> [<tree-ish>] [<path>...] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 15 | |
| 16 | DESCRIPTION |
| 17 | ----------- |
| 18 | Compares the content and mode of the blobs found via two tree objects. |
| 19 | |
| 20 | If there is only one <tree-ish> given, the commit is compared with its parents |
| 21 | (see --stdin below). |
| 22 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 23 | Note that 'git diff-tree' can use the tree encapsulated in a commit object. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 24 | |
| 25 | OPTIONS |
| 26 | ------- |
| 27 | include::diff-options.txt[] |
| 28 | |
| 29 | <tree-ish>:: |
| 30 | The id of a tree object. |
| 31 | |
| 32 | <path>...:: |
| 33 | If provided, the results are limited to a subset of files |
| 34 | matching one of these prefix strings. |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 35 | i.e., file matches `/^<pattern1>|<pattern2>|.../` |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 36 | Note that this parameter does not provide any wildcard or regexp |
| 37 | features. |
| 38 | |
| 39 | -r:: |
| 40 | recurse into sub-trees |
| 41 | |
| 42 | -t:: |
| 43 | show tree entry itself as well as subtrees. Implies -r. |
| 44 | |
| 45 | --root:: |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame] | 46 | When '--root' is specified the initial commit will be shown as a big |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 47 | creation event. This is equivalent to a diff against the NULL tree. |
| 48 | |
| 49 | --stdin:: |
| 50 | When '--stdin' is specified, the command does not take |
| 51 | <tree-ish> arguments from the command line. Instead, it |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 52 | reads lines containing either two <tree>, one <commit>, or a |
| 53 | list of <commit> from its standard input. (Use a single space |
| 54 | as separator.) |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 55 | + |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 56 | When two trees are given, it compares the first tree with the second. |
| 57 | When a single commit is given, it compares the commit with its |
| 58 | parents. The remaining commits, when given, are used as if they are |
Junio C Hamano | b53db3c | 2008-08-07 00:17:52 | [diff] [blame] | 59 | parents of the first commit. |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 60 | + |
| 61 | When comparing two trees, the ID of both trees (separated by a space |
| 62 | and terminated by a newline) is printed before the difference. When |
| 63 | comparing commits, the ID of the first (or only) commit, followed by a |
| 64 | newline, is printed. |
| 65 | + |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame] | 66 | The following flags further affect the behavior when comparing |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 67 | commits (but not trees). |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 68 | |
| 69 | -m:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 70 | By default, 'git diff-tree --stdin' does not show |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 71 | differences for merge commits. With this flag, it shows |
Junio C Hamano | a8adb1e | 2006-04-10 23:46:16 | [diff] [blame] | 72 | differences to that commit from all of its parents. See |
| 73 | also '-c'. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 74 | |
| 75 | -s:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 76 | By default, 'git diff-tree --stdin' shows differences, |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 77 | either in machine-readable form (without '-p') or in patch |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 78 | form (with '-p'). This output can be suppressed. It is |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 79 | only useful with '-v' flag. |
| 80 | |
| 81 | -v:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 82 | This flag causes 'git diff-tree --stdin' to also show |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 83 | the commit message before the differences. |
| 84 | |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 85 | include::pretty-options.txt[] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 86 | |
| 87 | --no-commit-id:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 88 | 'git diff-tree' outputs a line with the commit ID when |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 89 | applicable. This flag suppressed the commit ID output. |
| 90 | |
Junio C Hamano | a8adb1e | 2006-04-10 23:46:16 | [diff] [blame] | 91 | -c:: |
| 92 | This flag changes the way a merge commit is displayed |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 93 | (which means it is useful only when the command is given |
| 94 | one <tree-ish>, or '--stdin'). It shows the differences |
Junio C Hamano | a8adb1e | 2006-04-10 23:46:16 | [diff] [blame] | 95 | from each of the parents to the merge result simultaneously |
| 96 | instead of showing pairwise diff between a parent and the |
| 97 | result one at a time (which is what the '-m' option does). |
| 98 | Furthermore, it lists only files which were modified |
| 99 | from all parents. |
| 100 | |
Junio C Hamano | 46338f5 | 2006-05-04 00:46:44 | [diff] [blame] | 101 | --cc:: |
Junio C Hamano | a8adb1e | 2006-04-10 23:46:16 | [diff] [blame] | 102 | This flag changes the way a merge commit patch is displayed, |
| 103 | in a similar way to the '-c' option. It implies the '-c' |
| 104 | and '-p' options and further compresses the patch output |
Junio C Hamano | ccc2f76 | 2008-07-24 04:03:33 | [diff] [blame] | 105 | by omitting uninteresting hunks whose the contents in the parents |
| 106 | have only two variants and the merge result picks one of them |
| 107 | without modification. When all hunks are uninteresting, the commit |
| 108 | itself and the commit log message is not shown, just like in any other |
| 109 | "empty diff" case. |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 110 | |
Junio C Hamano | d9d71c0 | 2006-02-08 00:52:33 | [diff] [blame] | 111 | --always:: |
| 112 | Show the commit itself and the commit log message even |
| 113 | if the diff itself is empty. |
| 114 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 115 | |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 116 | include::pretty-formats.txt[] |
| 117 | |
| 118 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 119 | Limiting Output |
| 120 | --------------- |
| 121 | If you're only interested in differences in a subset of files, for |
| 122 | example some architecture-specific files, you might do: |
| 123 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 124 | git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64 |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 125 | |
| 126 | and it will only show you what changed in those two directories. |
| 127 | |
| 128 | Or if you are searching for what changed in just `kernel/sched.c`, just do |
| 129 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 130 | git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 131 | |
| 132 | and it will ignore all differences to other files. |
| 133 | |
| 134 | The pattern is always the prefix, and is matched exactly. There are no |
| 135 | wildcards. Even stricter, it has to match a complete path component. |
| 136 | I.e. "foo" does not pick up `foobar.h`. "foo" does match `foo/bar.h` |
| 137 | so it can be used to name subdirectories. |
| 138 | |
| 139 | An example of normal usage is: |
| 140 | |
Junio C Hamano | ef5a2f9 | 2011-05-31 19:53:33 | [diff] [blame] | 141 | torvalds@ppc970:~/git> git diff-tree --abbrev 5319e4 |
| 142 | :100664 100664 ac348b... a01513... git-fsck-objects.c |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 143 | |
| 144 | which tells you that the last commit changed just one file (it's from |
| 145 | this one: |
| 146 | |
| 147 | ----------------------------------------------------------------------------- |
| 148 | commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8 |
| 149 | tree 5319e4d609cdd282069cc4dce33c1db559539b03 |
| 150 | parent b4e628ea30d5ab3606119d2ea5caeab141d38df7 |
| 151 | author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005 |
| 152 | committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005 |
| 153 | |
| 154 | Make "git-fsck-objects" print out all the root commits it finds. |
| 155 | |
| 156 | Once I do the reference tracking, I'll also make it print out all the |
| 157 | HEAD commits it finds, which is even more interesting. |
| 158 | ----------------------------------------------------------------------------- |
| 159 | |
| 160 | in case you care). |
| 161 | |
Junio C Hamano | 543f8d6 | 2009-07-29 08:35:21 | [diff] [blame] | 162 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 163 | include::diff-format.txt[] |
| 164 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 165 | GIT |
| 166 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 167 | Part of the linkgit:git[1] suite |