2005-09-08 02:26:23 +02:00
|
|
|
git-diff(1)
|
|
|
|
===========
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2006-03-09 17:24:50 +01:00
|
|
|
git-diff - Show changes between commits, commit and working tree, etc
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2007-03-06 04:27:44 +01:00
|
|
|
'git-diff' [<common diff options>] <commit>{0,2} [--] [<path>...]
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
2006-07-09 11:59:39 +02:00
|
|
|
Show changes between two trees, a tree and the working tree, a
|
|
|
|
tree and the index file, or the index file and the working tree.
|
2005-09-08 08:04:52 +02:00
|
|
|
|
2006-12-14 09:03:18 +01:00
|
|
|
'git-diff' [--options] [--] [<path>...]::
|
2005-12-05 09:22:01 +01:00
|
|
|
|
2006-12-14 09:03:18 +01:00
|
|
|
This form is to view the changes you made relative to
|
|
|
|
the index (staging area for the next commit). In other
|
|
|
|
words, the differences are what you _could_ tell git to
|
|
|
|
further add to the index but you still haven't. You can
|
|
|
|
stage these changes by using gitlink:git-add[1].
|
|
|
|
|
2007-02-22 21:50:10 +01:00
|
|
|
If exactly two paths are given, and at least one is untracked,
|
|
|
|
compare the two files / directories. This behavior can be
|
|
|
|
forced by --no-index.
|
|
|
|
|
2006-12-14 09:03:18 +01:00
|
|
|
'git-diff' [--options] --cached [<commit>] [--] [<path>...]::
|
|
|
|
|
|
|
|
This form is to view the changes you staged for the next
|
2006-12-20 23:41:54 +01:00
|
|
|
commit relative to the named <commit>. Typically you
|
2006-12-14 09:03:18 +01:00
|
|
|
would want comparison with the latest commit, so if you
|
|
|
|
do not give <commit>, it defaults to HEAD.
|
|
|
|
|
2006-12-15 13:39:33 +01:00
|
|
|
'git-diff' [--options] <commit> [--] [<path>...]::
|
2006-12-14 09:03:18 +01:00
|
|
|
|
|
|
|
This form is to view the changes you have in your
|
|
|
|
working tree relative to the named <commit>. You can
|
|
|
|
use HEAD to compare it with the latest commit, or a
|
|
|
|
branch name to compare with the tip of a different
|
|
|
|
branch.
|
|
|
|
|
2006-12-15 13:39:33 +01:00
|
|
|
'git-diff' [--options] <commit> <commit> [--] [<path>...]::
|
2006-12-14 09:03:18 +01:00
|
|
|
|
|
|
|
This form is to view the changes between two <commit>,
|
|
|
|
for example, tips of two branches.
|
|
|
|
|
|
|
|
Just in case if you are doing something exotic, it should be
|
|
|
|
noted that all of the <commit> in the above description can be
|
|
|
|
any <tree-ish>.
|
2005-12-05 09:22:01 +01:00
|
|
|
|
2007-01-18 03:08:09 +01:00
|
|
|
For a more complete list of ways to spell <commit>, see
|
|
|
|
"SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
|
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-------
|
2006-12-14 09:03:18 +01:00
|
|
|
include::diff-options.txt[]
|
2005-09-08 08:04:52 +02:00
|
|
|
|
|
|
|
<path>...::
|
2006-12-14 09:03:18 +01:00
|
|
|
The <paths> parameters, when given, are used to limit
|
|
|
|
the diff to the named paths (you can give directory
|
|
|
|
names and get diff for all files under them).
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
|
2005-12-13 10:54:15 +01:00
|
|
|
EXAMPLES
|
|
|
|
--------
|
|
|
|
|
|
|
|
Various ways to check your working tree::
|
|
|
|
+
|
|
|
|
------------
|
2006-04-28 15:15:05 +02:00
|
|
|
$ git diff <1>
|
2006-12-13 10:33:43 +01:00
|
|
|
$ git diff --cached <2>
|
2006-04-28 15:15:05 +02:00
|
|
|
$ git diff HEAD <3>
|
|
|
|
------------
|
|
|
|
+
|
2006-12-14 09:03:18 +01:00
|
|
|
<1> changes in the working tree not yet staged for the next commit.
|
2005-12-13 10:54:15 +01:00
|
|
|
<2> changes between the index and your last commit; what you
|
|
|
|
would be committing if you run "git commit" without "-a" option.
|
|
|
|
<3> changes in the working tree since your last commit; what you
|
|
|
|
would be committing if you run "git commit -a"
|
|
|
|
|
|
|
|
Comparing with arbitrary commits::
|
|
|
|
+
|
|
|
|
------------
|
2006-04-28 15:15:05 +02:00
|
|
|
$ git diff test <1>
|
|
|
|
$ git diff HEAD -- ./test <2>
|
|
|
|
$ git diff HEAD^ HEAD <3>
|
|
|
|
------------
|
|
|
|
+
|
2005-12-13 10:54:15 +01:00
|
|
|
<1> instead of using the tip of the current branch, compare with the
|
|
|
|
tip of "test" branch.
|
|
|
|
<2> instead of comparing with the tip of "test" branch, compare with
|
2005-12-29 10:20:06 +01:00
|
|
|
the tip of the current branch, but limit the comparison to the
|
2005-12-13 10:54:15 +01:00
|
|
|
file "test".
|
|
|
|
<3> compare the version before the last commit and the last commit.
|
|
|
|
|
|
|
|
|
|
|
|
Limiting the diff output::
|
|
|
|
+
|
|
|
|
------------
|
2006-04-28 15:15:05 +02:00
|
|
|
$ git diff --diff-filter=MRC <1>
|
|
|
|
$ git diff --name-status -r <2>
|
|
|
|
$ git diff arch/i386 include/asm-i386 <3>
|
|
|
|
------------
|
|
|
|
+
|
2005-12-13 10:54:15 +01:00
|
|
|
<1> show only modification, rename and copy, but not addition
|
|
|
|
nor deletion.
|
|
|
|
<2> show only names and the nature of change, but not actual
|
|
|
|
diff output. --name-status disables usual patch generation
|
2006-06-03 22:27:26 +02:00
|
|
|
which in turn also disables recursive behavior, so without -r
|
2005-12-13 10:54:15 +01:00
|
|
|
you would only see the directory name if there is a change in a
|
|
|
|
file in a subdirectory.
|
|
|
|
<3> limit diff output to named subtrees.
|
|
|
|
|
|
|
|
Munging the diff output::
|
|
|
|
+
|
|
|
|
------------
|
2006-04-28 15:15:05 +02:00
|
|
|
$ git diff --find-copies-harder -B -C <1>
|
|
|
|
$ git diff -R <2>
|
|
|
|
------------
|
|
|
|
+
|
2005-12-13 10:54:15 +01:00
|
|
|
<1> spend extra cycles to find renames, copies and complete
|
|
|
|
rewrites (very expensive).
|
|
|
|
<2> output diff in reverse.
|
|
|
|
|
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
Author
|
|
|
|
------
|
|
|
|
Written by Linus Torvalds <torvalds@osdl.org>
|
|
|
|
|
|
|
|
Documentation
|
|
|
|
--------------
|
|
|
|
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
|
|
|
|
|
|
|
|
GIT
|
|
|
|
---
|
2005-09-19 12:10:51 +02:00
|
|
|
Part of the gitlink:git[7] suite
|
2005-08-23 10:49:47 +02:00
|
|
|
|