blob: 228c4d95bd41d40bbb32cfcb6b9a7dc648280fa5 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-diff(1)
2===========
3
4NAME
5----
Junio C Hamano01078922006-03-10 00:31:476git-diff - Show changes between commits, commit and working tree, etc
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano51c2ab02006-07-09 20:38:5411'git-diff' [ --diff-options ] <tree-ish>{0,2} [<path>...]
Junio C Hamano1a4e8412005-12-27 08:17:2312
13DESCRIPTION
14-----------
Junio C Hamano51c2ab02006-07-09 20:38:5415Show changes between two trees, a tree and the working tree, a
16tree and the index file, or the index file and the working tree.
Junio C Hamano1a4e8412005-12-27 08:17:2317The combination of what is compared with what is determined by
Junio C Hamano51c2ab02006-07-09 20:38:5418the number of trees given to the command.
Junio C Hamano1a4e8412005-12-27 08:17:2319
Junio C Hamano51c2ab02006-07-09 20:38:5420* When no <tree-ish> is given, the working tree and the index
21 file are compared, using `git-diff-files`.
Junio C Hamano1a4e8412005-12-27 08:17:2322
Junio C Hamano51c2ab02006-07-09 20:38:5423* When one <tree-ish> is given, the working tree and the named
24 tree are compared, using `git-diff-index`. The option
Junio C Hamano1a4e8412005-12-27 08:17:2325 `--cached` can be given to compare the index file and
26 the named tree.
27
Junio C Hamano51c2ab02006-07-09 20:38:5428* When two <tree-ish>s are given, these two trees are compared
Junio C Hamano1a4e8412005-12-27 08:17:2329 using `git-diff-tree`.
30
31OPTIONS
32-------
33--diff-options::
34'--diff-options' are passed to the `git-diff-files`,
35`git-diff-index`, and `git-diff-tree` commands. See the
36documentation for these commands for description.
37
38<path>...::
39The <path> arguments are also passed to `git-diff-\*`
40commands.
41
42
43EXAMPLES
44--------
45
46Various ways to check your working tree::
47+
48------------
Junio C Hamanoc8d88c22006-04-29 07:02:0149$ git diff <1>
50$ git diff --cached <2>
51$ git diff HEAD <3>
52------------
53+
Junio C Hamano1a4e8412005-12-27 08:17:2354<1> changes in the working tree since your last git-update-index.
55<2> changes between the index and your last commit; what you
56would be committing if you run "git commit" without "-a" option.
57<3> changes in the working tree since your last commit; what you
58would be committing if you run "git commit -a"
Junio C Hamano1a4e8412005-12-27 08:17:2359
60Comparing with arbitrary commits::
61+
62------------
Junio C Hamanoc8d88c22006-04-29 07:02:0163$ git diff test <1>
64$ git diff HEAD -- ./test <2>
65$ git diff HEAD^ HEAD <3>
66------------
67+
Junio C Hamano1a4e8412005-12-27 08:17:2368<1> instead of using the tip of the current branch, compare with the
69tip of "test" branch.
70<2> instead of comparing with the tip of "test" branch, compare with
Junio C Hamano235a91e2006-01-07 01:13:5871the tip of the current branch, but limit the comparison to the
Junio C Hamano1a4e8412005-12-27 08:17:2372file "test".
73<3> compare the version before the last commit and the last commit.
Junio C Hamano1a4e8412005-12-27 08:17:2374
75
76Limiting the diff output::
77+
78------------
Junio C Hamanoc8d88c22006-04-29 07:02:0179$ git diff --diff-filter=MRC <1>
80$ git diff --name-status -r <2>
81$ git diff arch/i386 include/asm-i386 <3>
82------------
83+
Junio C Hamano1a4e8412005-12-27 08:17:2384<1> show only modification, rename and copy, but not addition
85nor deletion.
86<2> show only names and the nature of change, but not actual
87diff output. --name-status disables usual patch generation
Junio C Hamano341071d2006-06-04 07:24:4888which in turn also disables recursive behavior, so without -r
Junio C Hamano1a4e8412005-12-27 08:17:2389you would only see the directory name if there is a change in a
90file in a subdirectory.
91<3> limit diff output to named subtrees.
Junio C Hamano1a4e8412005-12-27 08:17:2392
93Munging the diff output::
94+
95------------
Junio C Hamanoc8d88c22006-04-29 07:02:0196$ git diff --find-copies-harder -B -C <1>
97$ git diff -R <2>
98------------
99+
Junio C Hamano1a4e8412005-12-27 08:17:23100<1> spend extra cycles to find renames, copies and complete
101rewrites (very expensive).
102<2> output diff in reverse.
Junio C Hamano1a4e8412005-12-27 08:17:23103
104
105Author
106------
107Written by Linus Torvalds <torvalds@osdl.org>
108
109Documentation
110--------------
111Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
112
113GIT
114---
115Part of the gitlink:git[7] suite
116