Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
git
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Files
d516c2d
Documentation
howto
technical
.gitignore
Makefile
RelNotes-1.5.0.1.txt
RelNotes-1.5.0.txt
RelNotes-1.5.1.txt
SubmittingPatches
asciidoc.conf
build-docdep.perl
callouts.xsl
cmd-list.perl
config.txt
core-intro.txt
core-tutorial.txt
cvs-migration.txt
diff-format.txt
diff-options.txt
diffcore.txt
docbook-xsl.css
everyday.txt
fetch-options.txt
git-add.txt
git-am.txt
git-annotate.txt
git-apply.txt
git-applymbox.txt
git-applypatch.txt
git-archimport.txt
git-archive.txt
git-bisect.txt
git-blame.txt
git-branch.txt
git-cat-file.txt
git-check-ref-format.txt
git-checkout-index.txt
git-checkout.txt
git-cherry-pick.txt
git-cherry.txt
git-clean.txt
git-clone.txt
git-commit-tree.txt
git-commit.txt
git-config.txt
git-convert-objects.txt
git-count-objects.txt
git-cvsexportcommit.txt
git-cvsimport.txt
git-cvsserver.txt
git-daemon.txt
git-describe.txt
git-diff-files.txt
git-diff-index.txt
git-diff-tree.txt
git-diff.txt
git-fast-import.txt
git-fetch-pack.txt
git-fetch.txt
git-fmt-merge-msg.txt
git-for-each-ref.txt
git-format-patch.txt
git-fsck-objects.txt
git-fsck.txt
git-gc.txt
git-get-tar-commit-id.txt
git-grep.txt
git-hash-object.txt
git-http-fetch.txt
git-http-push.txt
git-imap-send.txt
git-index-pack.txt
git-init-db.txt
git-init.txt
git-instaweb.txt
git-local-fetch.txt
git-log.txt
git-lost-found.txt
git-ls-files.txt
git-ls-remote.txt
git-ls-tree.txt
git-mailinfo.txt
git-mailsplit.txt
git-merge-base.txt
git-merge-file.txt
git-merge-index.txt
git-merge-one-file.txt
git-merge-tree.txt
git-merge.txt
git-mktag.txt
git-mktree.txt
git-mv.txt
git-name-rev.txt
git-p4import.txt
git-pack-objects.txt
git-pack-redundant.txt
git-pack-refs.txt
git-parse-remote.txt
git-patch-id.txt
git-peek-remote.txt
git-prune-packed.txt
git-prune.txt
git-pull.txt
git-push.txt
git-quiltimport.txt
git-read-tree.txt
git-rebase.txt
git-receive-pack.txt
git-reflog.txt
git-relink.txt
git-remote.txt
git-repack.txt
git-repo-config.txt
git-request-pull.txt
git-rerere.txt
git-reset.txt
git-rev-list.txt
git-rev-parse.txt
git-revert.txt
git-rm.txt
git-runstatus.txt
git-send-email.txt
git-send-pack.txt
git-sh-setup.txt
git-shell.txt
git-shortlog.txt
git-show-branch.txt
git-show-index.txt
git-show-ref.txt
git-show.txt
git-ssh-fetch.txt
git-ssh-upload.txt
git-status.txt
git-stripspace.txt
git-svn.txt
git-svnimport.txt
git-symbolic-ref.txt
git-tag.txt
git-tar-tree.txt
git-tools.txt
git-unpack-file.txt
git-unpack-objects.txt
git-update-index.txt
git-update-ref.txt
git-update-server-info.txt
git-upload-archive.txt
git-upload-pack.txt
git-var.txt
git-verify-pack.txt
git-verify-tag.txt
git-whatchanged.txt
git-write-tree.txt
git.txt
gitk.txt
glossary.txt
hooks.txt
howto-index.sh
i18n.txt
install-doc-quick.sh
install-webdoc.sh
merge-options.txt
merge-strategies.txt
pretty-formats.txt
pull-fetch-param.txt
repository-layout.txt
sort_glossary.pl
tutorial-2.txt
tutorial.txt
urls.txt
user-manual.conf
user-manual.txt
arm
compat
contrib
git-gui
gitweb
mozilla-sha1
perl
ppc
t
templates
xdiff
.gitignore
.mailmap
COPYING
GIT-VERSION-GEN
INSTALL
Makefile
README
RelNotes
alloc.c
archive-tar.c
archive-zip.c
archive.h
base85.c
blob.c
blob.h
builtin-add.c
builtin-annotate.c
builtin-apply.c
builtin-archive.c
builtin-blame.c
builtin-branch.c
builtin-cat-file.c
builtin-check-ref-format.c
builtin-checkout-index.c
builtin-commit-tree.c
builtin-config.c
builtin-count-objects.c
builtin-describe.c
builtin-diff-files.c
builtin-diff-index.c
builtin-diff-tree.c
builtin-diff.c
builtin-fmt-merge-msg.c
builtin-for-each-ref.c
builtin-fsck.c
builtin-grep.c
builtin-init-db.c
builtin-log.c
builtin-ls-files.c
builtin-ls-tree.c
builtin-mailinfo.c
builtin-mailsplit.c
builtin-merge-base.c
builtin-merge-file.c
builtin-mv.c
builtin-name-rev.c
builtin-pack-objects.c
builtin-pack-refs.c
builtin-prune-packed.c
builtin-prune.c
builtin-push.c
builtin-read-tree.c
builtin-reflog.c
builtin-rerere.c
builtin-rev-list.c
builtin-rev-parse.c
builtin-rm.c
builtin-runstatus.c
builtin-shortlog.c
builtin-show-branch.c
builtin-show-ref.c
builtin-stripspace.c
builtin-symbolic-ref.c
builtin-tar-tree.c
builtin-unpack-objects.c
builtin-update-index.c
builtin-update-ref.c
builtin-upload-archive.c
builtin-verify-pack.c
builtin-write-tree.c
builtin.h
cache-tree.c
cache-tree.h
cache.h
check-builtins.sh
check-racy.c
color.c
color.h
combine-diff.c
commit.c
commit.h
config.c
config.mak.in
configure.ac
connect.c
convert-objects.c
copy.c
csum-file.c
csum-file.h
ctype.c
daemon.c
date.c
delta.h
diff-delta.c
diff-lib.c
diff.c
diff.h
diffcore-break.c
diffcore-delta.c
diffcore-order.c
diffcore-pickaxe.c
diffcore-rename.c
diffcore.h
dir.c
dir.h
dump-cache-tree.c
entry.c
environment.c
exec_cmd.c
exec_cmd.h
fast-import.c
fetch-pack.c
fetch.c
fetch.h
generate-cmdlist.sh
git-add--interactive.perl
git-am.sh
git-applymbox.sh
git-applypatch.sh
git-archimport.perl
git-bisect.sh
git-checkout.sh
git-clean.sh
git-clone.sh
git-commit.sh
git-compat-util.h
git-cvsexportcommit.perl
git-cvsimport.perl
git-cvsserver.perl
git-fetch.sh
git-gc.sh
git-instaweb.sh
git-lost-found.sh
git-ls-remote.sh
git-merge-octopus.sh
git-merge-one-file.sh
git-merge-ours.sh
git-merge-resolve.sh
git-merge-stupid.sh
git-merge.sh
git-p4import.py
git-parse-remote.sh
git-pull.sh
git-quiltimport.sh
git-rebase.sh
git-relink.perl
git-remote.perl
git-repack.sh
git-request-pull.sh
git-reset.sh
git-revert.sh
git-send-email.perl
git-sh-setup.sh
git-svn.perl
git-svnimport.perl
git-tag.sh
git-verify-tag.sh
git.c
git.spec.in
gitk
grep.c
grep.h
hash-object.c
help.c
http-fetch.c
http-push.c
http.c
http.h
ident.c
imap-send.c
index-pack.c
interpolate.c
interpolate.h
list-objects.c
list-objects.h
local-fetch.c
lockfile.c
log-tree.c
log-tree.h
merge-file.c
merge-index.c
merge-recursive.c
merge-tree.c
mktag.c
mktree.c
object-refs.c
object.c
object.h
pack-check.c
pack-redundant.c
pack.h
pager.c
patch-delta.c
patch-id.c
path-list.c
path-list.h
path.c
peek-remote.c
pkt-line.c
pkt-line.h
quote.c
quote.h
reachable.c
reachable.h
read-cache.c
receive-pack.c
reflog-walk.c
reflog-walk.h
refs.c
refs.h
revision.c
revision.h
rsh.c
rsh.h
run-command.c
run-command.h
send-pack.c
server-info.c
setup.c
sha1_file.c
sha1_name.c
shallow.c
shell.c
show-index.c
sideband.c
sideband.h
ssh-fetch.c
ssh-pull.c
ssh-push.c
ssh-upload.c
strbuf.c
strbuf.h
tag.c
tag.h
tar.h
test-date.c
test-delta.c
test-sha1.c
test-sha1.sh
trace.c
tree-diff.c
tree-walk.c
tree-walk.h
tree.c
tree.h
unpack-file.c
unpack-trees.c
unpack-trees.h
update-server-info.c
upload-pack.c
usage.c
utf8.c
utf8.h
var.c
write_or_die.c
wt-status.c
wt-status.h
xdiff-interface.c
xdiff-interface.h
Breadcrumbs
git
/
Documentation
/
git-diff.txt
Blame
Blame
Latest commit
History
History
141 lines (111 loc) · 3.88 KB
Breadcrumbs
git
/
Documentation
/
git-diff.txt
Top
File metadata and controls
Code
Blame
141 lines (111 loc) · 3.88 KB
Raw
git-diff(1) =========== NAME ---- git-diff - Show changes between commits, commit and working tree, etc SYNOPSIS -------- 'git-diff' [ --diff-options ] <commit>{0,2} [--] [<path>...] DESCRIPTION ----------- 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. 'git-diff' [--options] [--] [<path>...]:: 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]. 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. 'git-diff' [--options] --cached [<commit>] [--] [<path>...]:: This form is to view the changes you staged for the next commit relative to the named <commit>. Typically you would want comparison with the latest commit, so if you do not give <commit>, it defaults to HEAD. 'git-diff' [--options] <commit> [--] [<path>...]:: 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. 'git-diff' [--options] <commit> <commit> [--] [<path>...]:: 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>. For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1]. OPTIONS ------- include::diff-options.txt[] <path>...:: 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). EXAMPLES -------- Various ways to check your working tree:: + ------------ $ git diff <1> $ git diff --cached <2> $ git diff HEAD <3> ------------ + <1> changes in the working tree not yet staged for the next commit. <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:: + ------------ $ git diff test <1> $ git diff HEAD -- ./test <2> $ git diff HEAD^ HEAD <3> ------------ + <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 the tip of the current branch, but limit the comparison to the file "test". <3> compare the version before the last commit and the last commit. Limiting the diff output:: + ------------ $ git diff --diff-filter=MRC <1> $ git diff --name-status -r <2> $ git diff arch/i386 include/asm-i386 <3> ------------ + <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 which in turn also disables recursive behavior, so without -r 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:: + ------------ $ git diff --find-copies-harder -B -C <1> $ git diff -R <2> ------------ + <1> spend extra cycles to find renames, copies and complete rewrites (very expensive). <2> output diff in reverse. Author ------ Written by Linus Torvalds <torvalds@osdl.org> Documentation -------------- Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. GIT --- Part of the gitlink:git[7] suite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
You can’t perform that action at this time.