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