blob: c53eba557d0a242a0d8553d9569ce8b2eb86331b [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 Hamanofce7c7e2008-07-02 03:06:3811'git diff' [<common diff options>] <commit>{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:2317
Junio C Hamanofce7c7e2008-07-02 03:06:3818'git diff' [--options] [--] [<path>...]::
Junio C Hamano1a4e8412005-12-27 08:17:2319
Junio C Hamano47848ae2006-12-14 11:20:0620This form is to view the changes you made relative to
21the index (staging area for the next commit). In other
22words, the differences are what you _could_ tell git to
23further add to the index but you still haven't. You can
Junio C Hamano35738e82008-01-07 07:55:4624stage these changes by using linkgit:git-add[1].
Junio C Hamanoc435b1c2007-08-28 06:25:3525+
26If exactly two paths are given, and at least one is untracked,
27compare the two files / directories. This behavior can be
28forced by --no-index.
Junio C Hamanodb911ee2007-02-28 08:13:5229
Junio C Hamanofce7c7e2008-07-02 03:06:3830'git diff' [--options] --cached [<commit>] [--] [<path>...]::
Junio C Hamano47848ae2006-12-14 11:20:0631
32This form is to view the changes you staged for the next
Junio C Hamano4bf6dca2006-12-21 02:25:5733commit relative to the named <commit>. Typically you
Junio C Hamano47848ae2006-12-14 11:20:0634would want comparison with the latest commit, so if you
35do not give <commit>, it defaults to HEAD.
36
Junio C Hamanofce7c7e2008-07-02 03:06:3837'git diff' [--options] <commit> [--] [<path>...]::
Junio C Hamano47848ae2006-12-14 11:20:0638
39This form is to view the changes you have in your
40working tree relative to the named <commit>. You can
41use HEAD to compare it with the latest commit, or a
42branch name to compare with the tip of a different
43branch.
44
Junio C Hamanofce7c7e2008-07-02 03:06:3845'git diff' [--options] <commit> <commit> [--] [<path>...]::
Junio C Hamano47848ae2006-12-14 11:20:0646
Junio C Hamanoc435b1c2007-08-28 06:25:3547This is to view the changes between two arbitrary
48<commit>.
49
Junio C Hamanofce7c7e2008-07-02 03:06:3850'git diff' [--options] <commit>..<commit> [--] [<path>...]::
Junio C Hamanoc435b1c2007-08-28 06:25:3551
52This is synonymous to the previous form. If <commit> on
53one side is omitted, it will have the same effect as
54using HEAD instead.
55
Junio C Hamanofce7c7e2008-07-02 03:06:3856'git diff' [--options] <commit>\...<commit> [--] [<path>...]::
Junio C Hamanoc435b1c2007-08-28 06:25:3557
58This form is to view the changes on the branch containing
59and up to the second <commit>, starting at a common ancestor
Junio C Hamanofce7c7e2008-07-02 03:06:3860of both <commit>. "git diff A\...B" is equivalent to
61"git diff $(git-merge-base A B) B". You can omit any one
Junio C Hamanoc435b1c2007-08-28 06:25:3562of <commit>, which has the same effect as using HEAD instead.
Junio C Hamano47848ae2006-12-14 11:20:0663
64Just in case if you are doing something exotic, it should be
Junio C Hamano7d9e9bd2007-08-29 07:31:4765noted that all of the <commit> in the above description, except
66for the last two forms that use ".." notations, can be any
67<tree-ish>.
Junio C Hamano47848ae2006-12-14 11:20:0668
Junio C Hamano2d47c622007-01-18 06:24:1069For a more complete list of ways to spell <commit>, see
Junio C Hamano35738e82008-01-07 07:55:4670"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
Junio C Hamanoc435b1c2007-08-28 06:25:3571However, "diff" is about comparing two _endpoints_, not ranges,
72and the range notations ("<commit>..<commit>" and
Junio C Hamano7d9e9bd2007-08-29 07:31:4773"<commit>\...<commit>") do not mean a range as defined in the
Junio C Hamano35738e82008-01-07 07:55:4674"SPECIFYING RANGES" section in linkgit:git-rev-parse[1].
Junio C Hamano1a4e8412005-12-27 08:17:2375
76OPTIONS
77-------
Junio C Hamanoff979792007-11-16 10:11:3078:git-diff: 1
Junio C Hamano47848ae2006-12-14 11:20:0679include::diff-options.txt[]
Junio C Hamano1a4e8412005-12-27 08:17:2380
81<path>...::
Junio C Hamano47848ae2006-12-14 11:20:0682The <paths> parameters, when given, are used to limit
83the diff to the named paths (you can give directory
84names and get diff for all files under them).
Junio C Hamano1a4e8412005-12-27 08:17:2385
Junio C Hamano7ae0ab22007-11-03 02:46:4686Output format
87-------------
88include::diff-format.txt[]
Junio C Hamano1a4e8412005-12-27 08:17:2389
90EXAMPLES
91--------
92
93Various ways to check your working tree::
94+
95------------
Junio C Hamanoc8d88c22006-04-29 07:02:0196$ git diff <1>
Junio C Hamano47848ae2006-12-14 11:20:0697$ git diff --cached <2>
Junio C Hamanoc8d88c22006-04-29 07:02:0198$ git diff HEAD <3>
99------------
100+
Junio C Hamano092f5f02007-08-02 07:23:38101<1> Changes in the working tree not yet staged for the next commit.
102<2> Changes between the index and your last commit; what you
Junio C Hamano1a4e8412005-12-27 08:17:23103would be committing if you run "git commit" without "-a" option.
Junio C Hamano092f5f02007-08-02 07:23:38104<3> Changes in the working tree since your last commit; what you
Junio C Hamano1a4e8412005-12-27 08:17:23105would be committing if you run "git commit -a"
Junio C Hamano1a4e8412005-12-27 08:17:23106
107Comparing with arbitrary commits::
108+
109------------
Junio C Hamanoc8d88c22006-04-29 07:02:01110$ git diff test <1>
111$ git diff HEAD -- ./test <2>
112$ git diff HEAD^ HEAD <3>
113------------
114+
Junio C Hamano092f5f02007-08-02 07:23:38115<1> Instead of using the tip of the current branch, compare with the
Junio C Hamano1a4e8412005-12-27 08:17:23116tip of "test" branch.
Junio C Hamano092f5f02007-08-02 07:23:38117<2> Instead of comparing with the tip of "test" branch, compare with
Junio C Hamano235a91e2006-01-07 01:13:58118the tip of the current branch, but limit the comparison to the
Junio C Hamano1a4e8412005-12-27 08:17:23119file "test".
Junio C Hamano092f5f02007-08-02 07:23:38120<3> Compare the version before the last commit and the last commit.
Junio C Hamano1a4e8412005-12-27 08:17:23121
Junio C Hamanoc435b1c2007-08-28 06:25:35122Comparing branches::
123+
124------------
125$ git diff topic master <1>
126$ git diff topic..master <2>
127$ git diff topic...master <3>
128------------
129+
130<1> Changes between the tips of the topic and the master branches.
131<2> Same as above.
Junio C Hamano764a6672007-10-23 01:23:31132<3> Changes that occurred on the master branch since when the topic
Junio C Hamanoc435b1c2007-08-28 06:25:35133branch was started off it.
Junio C Hamano1a4e8412005-12-27 08:17:23134
135Limiting the diff output::
136+
137------------
Junio C Hamanoc8d88c22006-04-29 07:02:01138$ git diff --diff-filter=MRC <1>
Junio C Hamanobdeff822007-07-30 09:07:17139$ git diff --name-status <2>
Junio C Hamanoc8d88c22006-04-29 07:02:01140$ git diff arch/i386 include/asm-i386 <3>
141------------
142+
Junio C Hamano092f5f02007-08-02 07:23:38143<1> Show only modification, rename and copy, but not addition
Junio C Hamano1a4e8412005-12-27 08:17:23144nor deletion.
Junio C Hamano092f5f02007-08-02 07:23:38145<2> Show only names and the nature of change, but not actual
Junio C Hamanobdeff822007-07-30 09:07:17146diff output.
Junio C Hamano092f5f02007-08-02 07:23:38147<3> Limit diff output to named subtrees.
Junio C Hamano1a4e8412005-12-27 08:17:23148
149Munging the diff output::
150+
151------------
Junio C Hamanoc8d88c22006-04-29 07:02:01152$ git diff --find-copies-harder -B -C <1>
153$ git diff -R <2>
154------------
155+
Junio C Hamano092f5f02007-08-02 07:23:38156<1> Spend extra cycles to find renames, copies and complete
Junio C Hamano1a4e8412005-12-27 08:17:23157rewrites (very expensive).
Junio C Hamano092f5f02007-08-02 07:23:38158<2> Output diff in reverse.
Junio C Hamano1a4e8412005-12-27 08:17:23159
160
161Author
162------
163Written by Linus Torvalds <torvalds@osdl.org>
164
165Documentation
166--------------
167Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
168
169GIT
170---
Junio C Hamanof7c042d2008-06-06 22:50:53171Part of the linkgit:git[1] suite