]>
Commit | Line | Data |
---|---|---|
215a7ad1 JH |
1 | git-diff(1) |
2 | =========== | |
7fc9d69f JH |
3 | |
4 | NAME | |
5 | ---- | |
7bd7f280 | 6 | git-diff - Show changes between commits, commit and working tree, etc |
7fc9d69f JH |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
cfc01c03 | 11 | 'git-diff' [ --diff-options ] <tree-ish>{0,2} [<path>...] |
7fc9d69f JH |
12 | |
13 | DESCRIPTION | |
14 | ----------- | |
cfc01c03 ML |
15 | Show changes between two trees, a tree and the working tree, a |
16 | tree and the index file, or the index file and the working tree. | |
35ef3a4c | 17 | The combination of what is compared with what is determined by |
cfc01c03 | 18 | the number of trees given to the command. |
35ef3a4c | 19 | |
cfc01c03 ML |
20 | * When no <tree-ish> is given, the working tree and the index |
21 | file are compared, using `git-diff-files`. | |
dfa2f22f | 22 | |
cfc01c03 ML |
23 | * When one <tree-ish> is given, the working tree and the named |
24 | tree are compared, using `git-diff-index`. The option | |
f2dd1c9a | 25 | `--cached` can be given to compare the index file and |
dfa2f22f JH |
26 | the named tree. |
27 | ||
cfc01c03 | 28 | * When two <tree-ish>s are given, these two trees are compared |
dfa2f22f | 29 | using `git-diff-tree`. |
7fc9d69f JH |
30 | |
31 | OPTIONS | |
32 | ------- | |
35ef3a4c JH |
33 | --diff-options:: |
34 | '--diff-options' are passed to the `git-diff-files`, | |
35 | `git-diff-index`, and `git-diff-tree` commands. See the | |
36 | documentation for these commands for description. | |
37 | ||
38 | <path>...:: | |
39 | The <path> arguments are also passed to `git-diff-\*` | |
40 | commands. | |
7fc9d69f JH |
41 | |
42 | ||
803f498c JH |
43 | EXAMPLES |
44 | -------- | |
45 | ||
46 | Various ways to check your working tree:: | |
47 | + | |
48 | ------------ | |
48aeecdc | 49 | $ git diff <1> |
f2dd1c9a | 50 | $ git diff --cached <2> |
48aeecdc SE |
51 | $ git diff HEAD <3> |
52 | ------------ | |
53 | + | |
803f498c JH |
54 | <1> changes in the working tree since your last git-update-index. |
55 | <2> changes between the index and your last commit; what you | |
56 | would be committing if you run "git commit" without "-a" option. | |
57 | <3> changes in the working tree since your last commit; what you | |
58 | would be committing if you run "git commit -a" | |
803f498c JH |
59 | |
60 | Comparing with arbitrary commits:: | |
61 | + | |
62 | ------------ | |
48aeecdc SE |
63 | $ git diff test <1> |
64 | $ git diff HEAD -- ./test <2> | |
65 | $ git diff HEAD^ HEAD <3> | |
66 | ------------ | |
67 | + | |
803f498c JH |
68 | <1> instead of using the tip of the current branch, compare with the |
69 | tip of "test" branch. | |
70 | <2> instead of comparing with the tip of "test" branch, compare with | |
89438677 | 71 | the tip of the current branch, but limit the comparison to the |
803f498c JH |
72 | file "test". |
73 | <3> compare the version before the last commit and the last commit. | |
803f498c JH |
74 | |
75 | ||
76 | Limiting the diff output:: | |
77 | + | |
78 | ------------ | |
48aeecdc SE |
79 | $ git diff --diff-filter=MRC <1> |
80 | $ git diff --name-status -r <2> | |
81 | $ git diff arch/i386 include/asm-i386 <3> | |
82 | ------------ | |
83 | + | |
803f498c JH |
84 | <1> show only modification, rename and copy, but not addition |
85 | nor deletion. | |
86 | <2> show only names and the nature of change, but not actual | |
87 | diff output. --name-status disables usual patch generation | |
abda1ef5 | 88 | which in turn also disables recursive behavior, so without -r |
803f498c JH |
89 | you would only see the directory name if there is a change in a |
90 | file in a subdirectory. | |
91 | <3> limit diff output to named subtrees. | |
803f498c JH |
92 | |
93 | Munging the diff output:: | |
94 | + | |
95 | ------------ | |
48aeecdc SE |
96 | $ git diff --find-copies-harder -B -C <1> |
97 | $ git diff -R <2> | |
98 | ------------ | |
99 | + | |
803f498c JH |
100 | <1> spend extra cycles to find renames, copies and complete |
101 | rewrites (very expensive). | |
102 | <2> output diff in reverse. | |
803f498c JH |
103 | |
104 | ||
7fc9d69f JH |
105 | Author |
106 | ------ | |
107 | Written by Linus Torvalds <torvalds@osdl.org> | |
108 | ||
109 | Documentation | |
110 | -------------- | |
111 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. | |
112 | ||
113 | GIT | |
114 | --- | |
a7154e91 | 115 | Part of the gitlink:git[7] suite |
7fc9d69f | 116 |