logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-diff.1 (75906B)


  1. '\" t
  2. .\" Title: git-diff
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-DIFF" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-diff \- Show changes between commits, commit and working tree, etc
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fI<commit>\fR] [\fB\-\-\fR] [\fI<path>\fR\&...\:]
  36. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-cached\fR [\fB\-\-merge\-base\fR] [\fI<commit>\fR] [\fB\-\-\fR] [\fI<path>\fR\&...\:]
  37. \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-merge\-base\fR] \fI<commit>\fR [\fI<commit>\fR\&...\:] \fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&...\:]
  38. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR`\&...\:\fB__\fR\fI<commit>\fR\fB__\fR [{empty}\-\-{empty}]{empty} [\fB__\fR\fI<path>\fR\fB__\&.\&.\fR\&.]{empty}
  39. {empty}`git \fBdiff\fR [\fI<options>\fR] \fI<blob>\fR \fI<blob>\fR
  40. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-no\-index\fR [\fB\-\-\fR] \fI<path>\fR \fI<path>\fR
  41. .fi
  42. .SH "DESCRIPTION"
  43. .sp
  44. Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk\&.
  45. .PP
  46. \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  47. .RS 4
  48. 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
  49. \fIcould\fR
  50. tell Git to further add to the index but you still haven\(cqt\&. You can stage these changes by using
  51. \fBgit-add\fR(1)\&.
  52. .RE
  53. .PP
  54. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-no\-index\fR [\fB\-\-\fR] \fI<path>\fR \fI<path>\fR
  55. .RS 4
  56. This form is to compare the given two paths on the filesystem\&. You can omit the
  57. \fB\-\-no\-index\fR
  58. option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git\&. This form implies
  59. \fB\-\-exit\-code\fR\&.
  60. .RE
  61. .PP
  62. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-cached\fR [\fB\-\-merge\-base\fR] [\fI<commit>\fR] [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  63. .RS 4
  64. This form is to view the changes you staged for the next commit relative to the named
  65. \fI<commit>\fR\&. Typically you would want comparison with the latest commit, so if you do not give
  66. \fI<commit>\fR, it defaults to
  67. \fBHEAD\fR\&. If
  68. \fBHEAD\fR
  69. does not exist (e\&.g\&. unborn branches) and
  70. \fI<commit>\fR
  71. is not given, it shows all staged changes\&.
  72. \fB\-\-staged\fR
  73. is a synonym of
  74. \fB\-\-cached\fR\&.
  75. .sp
  76. If
  77. \fB\-\-merge\-base\fR
  78. is given, instead of using
  79. \fI<commit>\fR, use the merge base of
  80. \fI<commit>\fR
  81. and
  82. \fBHEAD\fR\&.
  83. \fBgit\fR
  84. \fBdiff\fR
  85. \fB\-\-cached\fR
  86. \fB\-\-merge\-base\fR
  87. \fBA\fR
  88. is equivalent to
  89. \fBgit\fR
  90. \fBdiff\fR
  91. \fB\-\-cached\fR
  92. \fB$\fR(\fBgit\fR
  93. \fBmerge\-base\fR
  94. \fBA\fR
  95. \fBHEAD\fR)\&.
  96. .RE
  97. .PP
  98. \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-merge\-base\fR] \fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  99. .RS 4
  100. This form is to view the changes you have in your working tree relative to the named
  101. \fI<commit>\fR\&. You can use
  102. \fBHEAD\fR
  103. to compare it with the latest commit, or a branch name to compare with the tip of a different branch\&.
  104. .sp
  105. If
  106. \fB\-\-merge\-base\fR
  107. is given, instead of using
  108. \fI<commit>\fR, use the merge base of
  109. \fI<commit>\fR
  110. and
  111. \fBHEAD\fR\&.
  112. \fBgit\fR
  113. \fBdiff\fR
  114. \fB\-\-merge\-base\fR
  115. \fBA\fR
  116. is equivalent to
  117. \fBgit\fR
  118. \fBdiff\fR
  119. \fB$\fR(\fBgit\fR
  120. \fBmerge\-base\fR
  121. \fBA\fR
  122. \fBHEAD\fR)\&.
  123. .RE
  124. .PP
  125. \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-merge\-base\fR] \fI<commit>\fR \fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  126. .RS 4
  127. This is to view the changes between two arbitrary
  128. \fI<commit>\fR\&.
  129. .sp
  130. If
  131. \fB\-\-merge\-base\fR
  132. is given, use the merge base of the two commits for the "before" side\&.
  133. \fBgit\fR
  134. \fBdiff\fR
  135. \fB\-\-merge\-base\fR
  136. \fBA\fR
  137. \fBB\fR
  138. is equivalent to
  139. \fBgit\fR
  140. \fBdiff\fR
  141. \fB$\fR(\fBgit\fR
  142. \fBmerge\-base\fR
  143. \fBA\fR
  144. \fBB\fR)
  145. \fBB\fR\&.
  146. .RE
  147. .PP
  148. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR \fI<commit>\fR\fB\&.\&.\&.\fR\fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  149. .RS 4
  150. This form is to view the results of a merge commit\&. The first listed
  151. \fI<commit>\fR
  152. must be the merge itself; the remaining two or more commits should be its parents\&. Convenient ways to produce the desired set of revisions are to use the suffixes
  153. \fB@\fR
  154. and
  155. \fB^\fR!\&. If
  156. \fBA\fR
  157. is a merge commit, then
  158. \fBgit\fR
  159. \fBdiff\fR
  160. \fBA\fR
  161. \fBA^@\fR,
  162. \fBgit\fR
  163. \fBdiff\fR
  164. \fBA^\fR! and
  165. \fBgit\fR
  166. \fBshow\fR
  167. \fBA\fR
  168. all give the same combined diff\&.
  169. .RE
  170. .PP
  171. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR\fB\&.\&.\fR\fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  172. .RS 4
  173. This is synonymous to the earlier form (without the \&.\&.) for viewing the changes between two arbitrary
  174. \fI<commit>\fR\&. If
  175. \fI<commit>\fR
  176. on one side is omitted, it will have the same effect as using
  177. \fBHEAD\fR
  178. instead\&.
  179. .RE
  180. .PP
  181. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR\fB\&.\&.\&.\fR\fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
  182. .RS 4
  183. This form is to view the changes on the branch containing and up to the second
  184. \fI<commit>\fR, starting at a common ancestor of both
  185. \fI<commit>\fR\&.
  186. \fBgit\fR
  187. \fBdiff\fR
  188. \fBA\fR\fB\&.\&.\&.\fR\fBB\fR
  189. is equivalent to
  190. \fBgit\fR
  191. \fBdiff\fR
  192. \fB$\fR(\fBgit\fR
  193. \fBmerge\-base\fR
  194. \fBA\fR
  195. \fBB\fR)
  196. \fBB\fR\&. You can omit any one of
  197. \fI<commit>\fR, which has the same effect as using
  198. \fBHEAD\fR
  199. instead\&.
  200. .RE
  201. .sp
  202. Just in case you are doing something exotic, it should be noted that all of the \fI<commit>\fR in the above description, except in the \fB\-\-merge\-base\fR case and in the last two forms that use \&.\&. notations, can be any \fI<tree>\fR\&. A tree of interest is the one pointed to by the ref named \fBAUTO_MERGE\fR, which is written by the \fBort\fR merge strategy upon hitting merge conflicts (see \fBgit-merge\fR(1))\&. Comparing the working tree with \fBAUTO_MERGE\fR shows changes you\(cqve made so far to resolve textual conflicts (see the examples below)\&.
  203. .sp
  204. For a more complete list of ways to spell \fI<commit>\fR, see "SPECIFYING REVISIONS" section in \fBgitrevisions\fR(7)\&. However, \fBdiff\fR is about comparing two \fIendpoints\fR, not ranges, and the range notations (\fI<commit>\fR\fB\&.\&.\fR\fI<commit>\fR and \fI<commit>\fR\fB\&.\&.\&.\fR\fI<commit>\fR) do not mean a range as defined in the "SPECIFYING RANGES" section in \fBgitrevisions\fR(7)\&.
  205. .PP
  206. \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<blob>\fR \fI<blob>\fR
  207. .RS 4
  208. This form is to view the differences between the raw contents of two blob objects\&.
  209. .RE
  210. .SH "OPTIONS"
  211. .PP
  212. \fB\-p\fR, \fB\-u\fR, \fB\-\-patch\fR
  213. .RS 4
  214. Generate patch (see
  215. the section called \(lqGENERATING PATCH TEXT WITH \-P\(rq)\&. This is the default\&.
  216. .RE
  217. .PP
  218. \fB\-s\fR, \fB\-\-no\-patch\fR
  219. .RS 4
  220. Suppress all output from the diff machinery\&. Useful for commands like
  221. \fBgit\fR
  222. \fBshow\fR
  223. that show the patch by default to squelch their output, or to cancel the effect of options like
  224. \fB\-\-patch\fR,
  225. \fB\-\-stat\fR
  226. earlier on the command line in an alias\&.
  227. .RE
  228. .PP
  229. \fB\-U\fR\fI<n>\fR, \fB\-\-unified=\fR\fI<n>\fR
  230. .RS 4
  231. Generate diffs with
  232. \fI<n>\fR
  233. lines of context instead of the usual three\&. Implies
  234. \fB\-\-patch\fR\&.
  235. .RE
  236. .PP
  237. \fB\-\-output=\fR\fI<file>\fR
  238. .RS 4
  239. Output to a specific file instead of stdout\&.
  240. .RE
  241. .PP
  242. \fB\-\-output\-indicator\-new=\fR\fI<char>\fR, \fB\-\-output\-indicator\-old=\fR\fI<char>\fR, \fB\-\-output\-indicator\-context=\fR\fI<char>\fR
  243. .RS 4
  244. Specify the character used to indicate new, old or context lines in the generated patch\&. Normally they are
  245. \fB+\fR,
  246. \fB\-\fR
  247. and \*(Aq \*(Aq respectively\&.
  248. .RE
  249. .PP
  250. \fB\-\-raw\fR
  251. .RS 4
  252. Generate the diff in raw format\&.
  253. .RE
  254. .PP
  255. \fB\-\-patch\-with\-raw\fR
  256. .RS 4
  257. Synonym for
  258. \fB\-p\fR
  259. \fB\-\-raw\fR\&.
  260. .RE
  261. .PP
  262. \fB\-\-indent\-heuristic\fR
  263. .RS 4
  264. Enable the heuristic that shifts diff hunk boundaries to make patches easier to read\&. This is the default\&.
  265. .RE
  266. .PP
  267. \fB\-\-no\-indent\-heuristic\fR
  268. .RS 4
  269. Disable the indent heuristic\&.
  270. .RE
  271. .PP
  272. \fB\-\-minimal\fR
  273. .RS 4
  274. Spend extra time to make sure the smallest possible diff is produced\&.
  275. .RE
  276. .PP
  277. \fB\-\-patience\fR
  278. .RS 4
  279. Generate a diff using the "patience diff" algorithm\&.
  280. .RE
  281. .PP
  282. \fB\-\-histogram\fR
  283. .RS 4
  284. Generate a diff using the "histogram diff" algorithm\&.
  285. .RE
  286. .PP
  287. \fB\-\-anchored=\fR\fI<text>\fR
  288. .RS 4
  289. Generate a diff using the "anchored diff" algorithm\&.
  290. .sp
  291. This option may be specified more than once\&.
  292. .sp
  293. If a line exists in both the source and destination, exists only once, and starts with
  294. \fI<text>\fR, this algorithm attempts to prevent it from appearing as a deletion or addition in the output\&. It uses the "patience diff" algorithm internally\&.
  295. .RE
  296. .PP
  297. \fB\-\-diff\-algorithm=\fR(\fBpatience\fR|\fBminimal\fR|\fBhistogram\fR|\fBmyers\fR)
  298. .RS 4
  299. Choose a diff algorithm\&. The variants are as follows:
  300. .PP
  301. \fBdefault\fR, \fBmyers\fR
  302. .RS 4
  303. The basic greedy diff algorithm\&. Currently, this is the default\&.
  304. .RE
  305. .PP
  306. \fBminimal\fR
  307. .RS 4
  308. Spend extra time to make sure the smallest possible diff is produced\&.
  309. .RE
  310. .PP
  311. \fBpatience\fR
  312. .RS 4
  313. Use "patience diff" algorithm when generating patches\&.
  314. .RE
  315. .PP
  316. \fBhistogram\fR
  317. .RS 4
  318. This algorithm extends the patience algorithm to "support low\-occurrence common elements"\&.
  319. .RE
  320. .sp
  321. For instance, if you configured the
  322. \fBdiff\&.algorithm\fR
  323. variable to a non\-default value and want to use the default one, then you have to use
  324. \fB\-\-diff\-algorithm=default\fR
  325. option\&.
  326. .RE
  327. .PP
  328. \fB\-\-stat\fR[\fB=\fR\fI<width>\fR[\fB,\fR\fI<name\-width>\fR[\fB,\fR\fI<count>\fR]]]
  329. .RS 4
  330. Generate a diffstat\&. By default, as much space as necessary will be used for the filename part, and the rest for the graph part\&. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by
  331. \fI<width>\fR\&. The width of the filename part can be limited by giving another width
  332. \fI<name\-width>\fR
  333. after a comma or by setting
  334. \fBdiff\&.statNameWidth=\fR\fI<name\-width>\fR\&. The width of the graph part can be limited by using
  335. \fB\-\-stat\-graph\-width=\fR\fI<graph\-width>\fR
  336. or by setting
  337. \fBdiff\&.statGraphWidth=\fR\fI<graph\-width>\fR\&. Using
  338. \fB\-\-stat\fR
  339. or
  340. \fB\-\-stat\-graph\-width\fR
  341. affects all commands generating a stat graph, while setting
  342. \fBdiff\&.statNameWidth\fR
  343. or
  344. \fBdiff\&.statGraphWidth\fR
  345. does not affect
  346. \fBgit\fR
  347. \fBformat\-patch\fR\&. By giving a third parameter
  348. \fI<count>\fR, you can limit the output to the first
  349. \fI<count>\fR
  350. lines, followed by \&.\&.\&. if there are more\&.
  351. .sp
  352. These parameters can also be set individually with
  353. \fB\-\-stat\-width=\fR\fI<width>\fR,
  354. \fB\-\-stat\-name\-width=\fR\fI<name\-width>\fR
  355. and
  356. \fB\-\-stat\-count=\fR\fI<count>\fR\&.
  357. .RE
  358. .PP
  359. \fB\-\-compact\-summary\fR
  360. .RS 4
  361. Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally
  362. \fB+l\fR
  363. if it\(cqs a symlink) and mode changes (\fB+x\fR
  364. or
  365. \fB\-x\fR
  366. for adding or removing executable bit respectively) in diffstat\&. The information is put between the filename part and the graph part\&. Implies
  367. \fB\-\-stat\fR\&.
  368. .RE
  369. .PP
  370. \fB\-\-numstat\fR
  371. .RS 4
  372. Similar to
  373. \fB\-\-stat\fR, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly\&. For binary files, outputs two
  374. \fB\-\fR
  375. instead of saying
  376. \fB0\fR
  377. \fB0\fR\&.
  378. .RE
  379. .PP
  380. \fB\-\-shortstat\fR
  381. .RS 4
  382. Output only the last line of the
  383. \fB\-\-stat\fR
  384. format containing total number of modified files, as well as number of added and deleted lines\&.
  385. .RE
  386. .PP
  387. \fB\-X\fR [\fI<param>\fR\fB,\&.\&.\fR\&.], \fB\-\-dirstat\fR[\fB=\fR\fI<param>\fR\fB,\&.\&.\fR\&.]
  388. .RS 4
  389. Output the distribution of relative amount of changes for each sub\-directory\&. The behavior of
  390. \fB\-\-dirstat\fR
  391. can be customized by passing it a comma separated list of parameters\&. The defaults are controlled by the
  392. \fBdiff\&.dirstat\fR
  393. configuration variable (see
  394. \fBgit-config\fR(1))\&. The following parameters are available:
  395. .PP
  396. \fBchanges\fR
  397. .RS 4
  398. Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination\&. This ignores the amount of pure code movements within a file\&. In other words, rearranging lines in a file is not counted as much as other changes\&. This is the default behavior when no parameter is given\&.
  399. .RE
  400. .PP
  401. \fBlines\fR
  402. .RS 4
  403. Compute the dirstat numbers by doing the regular line\-based diff analysis, and summing the removed/added line counts\&. (For binary files, count 64\-byte chunks instead, since binary files have no natural concept of lines)\&. This is a more expensive
  404. \fB\-\-dirstat\fR
  405. behavior than the
  406. \fBchanges\fR
  407. behavior, but it does count rearranged lines within a file as much as other changes\&. The resulting output is consistent with what you get from the other
  408. \fB\-\-\fR*stat options\&.
  409. .RE
  410. .PP
  411. \fBfiles\fR
  412. .RS 4
  413. Compute the dirstat numbers by counting the number of files changed\&. Each changed file counts equally in the dirstat analysis\&. This is the computationally cheapest
  414. \fB\-\-dirstat\fR
  415. behavior, since it does not have to look at the file contents at all\&.
  416. .RE
  417. .PP
  418. \fBcumulative\fR
  419. .RS 4
  420. Count changes in a child directory for the parent directory as well\&. Note that when using
  421. \fBcumulative\fR, the sum of the percentages reported may exceed 100%\&. The default (non\-cumulative) behavior can be specified with the
  422. \fBnoncumulative\fR
  423. parameter\&.
  424. .RE
  425. .PP
  426. \fI<limit>\fR
  427. .RS 4
  428. An integer parameter specifies a cut\-off percent (3% by default)\&. Directories contributing less than this percentage of the changes are not shown in the output\&.
  429. .RE
  430. .sp
  431. Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories:
  432. \fB\-\-dirstat=files,10,cumulative\fR\&.
  433. .RE
  434. .PP
  435. \fB\-\-cumulative\fR
  436. .RS 4
  437. Synonym for
  438. \fB\-\-dirstat=cumulative\fR\&.
  439. .RE
  440. .PP
  441. \fB\-\-dirstat\-by\-file\fR[\fB=\fR\fI<param>\fR\fB,\&.\&.\fR\&.]
  442. .RS 4
  443. Synonym for
  444. \fB\-\-dirstat=files,\fR\fI<param>\fR\fB,\&.\&.\fR\&.\&.
  445. .RE
  446. .PP
  447. \fB\-\-summary\fR
  448. .RS 4
  449. Output a condensed summary of extended header information such as creations, renames and mode changes\&.
  450. .RE
  451. .PP
  452. \fB\-\-patch\-with\-stat\fR
  453. .RS 4
  454. Synonym for
  455. \fB\-p\fR
  456. \fB\-\-stat\fR\&.
  457. .RE
  458. .PP
  459. \fB\-z\fR
  460. .RS 4
  461. When
  462. \fB\-\-raw\fR,
  463. \fB\-\-numstat\fR,
  464. \fB\-\-name\-only\fR
  465. or
  466. \fB\-\-name\-status\fR
  467. has been given, do not munge pathnames and use NULs as output field terminators\&.
  468. .sp
  469. Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable
  470. \fBcore\&.quotePath\fR
  471. (see
  472. \fBgit-config\fR(1))\&.
  473. .RE
  474. .PP
  475. \fB\-\-name\-only\fR
  476. .RS 4
  477. Show only the name of each changed file in the post\-image tree\&. The file names are often encoded in UTF\-8\&. For more information see the discussion about encoding in the
  478. \fBgit-log\fR(1)
  479. manual page\&.
  480. .RE
  481. .PP
  482. \fB\-\-name\-status\fR
  483. .RS 4
  484. Show only the name(s) and status of each changed file\&. See the description of the
  485. \fB\-\-diff\-filter\fR
  486. option on what the status letters mean\&. Just like
  487. \fB\-\-name\-only\fR
  488. the file names are often encoded in UTF\-8\&.
  489. .RE
  490. .PP
  491. \fB\-\-submodule\fR[\fB=\fR\fI<format>\fR]
  492. .RS 4
  493. Specify how differences in submodules are shown\&. When specifying
  494. \fB\-\-submodule=short\fR
  495. the
  496. \fBshort\fR
  497. format is used\&. This format just shows the names of the commits at the beginning and end of the range\&. When
  498. \fB\-\-submodule\fR
  499. or
  500. \fB\-\-submodule=log\fR
  501. is specified, the
  502. \fBlog\fR
  503. format is used\&. This format lists the commits in the range like
  504. \fBgit-submodule\fR(1)
  505. \fBsummary\fR
  506. does\&. When
  507. \fB\-\-submodule=diff\fR
  508. is specified, the
  509. \fBdiff\fR
  510. format is used\&. This format shows an inline diff of the changes in the submodule contents between the commit range\&. Defaults to
  511. \fBdiff\&.submodule\fR
  512. or the
  513. \fBshort\fR
  514. format if the config option is unset\&.
  515. .RE
  516. .PP
  517. \fB\-\-color\fR[\fB=\fR\fI<when>\fR]
  518. .RS 4
  519. Show colored diff\&.
  520. \fB\-\-color\fR
  521. (i\&.e\&. without
  522. \fB=\fR\fI<when>\fR) is the same as
  523. \fB\-\-color=always\fR\&.
  524. \fI<when>\fR
  525. can be one of
  526. \fBalways\fR,
  527. \fBnever\fR, or
  528. \fBauto\fR\&. It can be changed by the
  529. \fBcolor\&.ui\fR
  530. and
  531. \fBcolor\&.diff\fR
  532. configuration settings\&.
  533. .RE
  534. .PP
  535. \fB\-\-no\-color\fR
  536. .RS 4
  537. Turn off colored diff\&. This can be used to override configuration settings\&. It is the same as
  538. \fB\-\-color=never\fR\&.
  539. .RE
  540. .PP
  541. \fB\-\-color\-moved\fR[\fB=\fR\fI<mode>\fR]
  542. .RS 4
  543. Moved lines of code are colored differently\&. It can be changed by the
  544. \fBdiff\&.colorMoved\fR
  545. configuration setting\&. The
  546. \fI<mode>\fR
  547. defaults to
  548. \fBno\fR
  549. if the option is not given and to
  550. \fBzebra\fR
  551. if the option with no mode is given\&. The mode must be one of:
  552. .PP
  553. \fBno\fR
  554. .RS 4
  555. Moved lines are not highlighted\&.
  556. .RE
  557. .PP
  558. \fBdefault\fR
  559. .RS 4
  560. Is a synonym for
  561. \fBzebra\fR\&. This may change to a more sensible mode in the future\&.
  562. .RE
  563. .PP
  564. \fBplain\fR
  565. .RS 4
  566. Any line that is added in one location and was removed in another location will be colored with
  567. \fBcolor\&.diff\&.newMoved\fR\&. Similarly
  568. \fBcolor\&.diff\&.oldMoved\fR
  569. will be used for removed lines that are added somewhere else in the diff\&. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation\&.
  570. .RE
  571. .PP
  572. \fBblocks\fR
  573. .RS 4
  574. Blocks of moved text of at least 20 alphanumeric characters are detected greedily\&. The detected blocks are painted using either the
  575. \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMoved\fR
  576. color\&. Adjacent blocks cannot be told apart\&.
  577. .RE
  578. .PP
  579. \fBzebra\fR
  580. .RS 4
  581. Blocks of moved text are detected as in
  582. \fBblocks\fR
  583. mode\&. The blocks are painted using either the
  584. \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMoved\fR
  585. color or
  586. \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMovedAlternative\fR\&. The change between the two colors indicates that a new block was detected\&.
  587. .RE
  588. .PP
  589. \fBdimmed\-zebra\fR
  590. .RS 4
  591. Similar to
  592. \fBzebra\fR, but additional dimming of uninteresting parts of moved code is performed\&. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting\&.
  593. \fBdimmed_zebra\fR
  594. is a deprecated synonym\&.
  595. .RE
  596. .RE
  597. .PP
  598. \fB\-\-no\-color\-moved\fR
  599. .RS 4
  600. Turn off move detection\&. This can be used to override configuration settings\&. It is the same as
  601. \fB\-\-color\-moved=no\fR\&.
  602. .RE
  603. .PP
  604. \fB\-\-color\-moved\-ws=\fR\fI<mode>\fR\fB,\&.\&.\fR\&.
  605. .RS 4
  606. This configures how whitespace is ignored when performing the move detection for
  607. \fB\-\-color\-moved\fR\&. It can be set by the
  608. \fBdiff\&.colorMovedWS\fR
  609. configuration setting\&. These modes can be given as a comma separated list:
  610. .PP
  611. \fBno\fR
  612. .RS 4
  613. Do not ignore whitespace when performing move detection\&.
  614. .RE
  615. .PP
  616. \fBignore\-space\-at\-eol\fR
  617. .RS 4
  618. Ignore changes in whitespace at EOL\&.
  619. .RE
  620. .PP
  621. \fBignore\-space\-change\fR
  622. .RS 4
  623. Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
  624. .RE
  625. .PP
  626. \fBignore\-all\-space\fR
  627. .RS 4
  628. Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
  629. .RE
  630. .PP
  631. \fBallow\-indentation\-change\fR
  632. .RS 4
  633. Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line\&. This is incompatible with the other modes\&.
  634. .RE
  635. .RE
  636. .PP
  637. \fB\-\-no\-color\-moved\-ws\fR
  638. .RS 4
  639. Do not ignore whitespace when performing move detection\&. This can be used to override configuration settings\&. It is the same as
  640. \fB\-\-color\-moved\-ws=no\fR\&.
  641. .RE
  642. .PP
  643. \fB\-\-word\-diff\fR[\fB=\fR\fI<mode>\fR]
  644. .RS 4
  645. By default, words are delimited by whitespace; see
  646. \fB\-\-word\-diff\-regex\fR
  647. below\&. The
  648. \fI<mode>\fR
  649. defaults to
  650. \fBplain\fR, and must be one of:
  651. .PP
  652. \fBcolor\fR
  653. .RS 4
  654. Highlight changed words using only colors\&. Implies
  655. \fB\-\-color\fR\&.
  656. .RE
  657. .PP
  658. \fBplain\fR
  659. .RS 4
  660. Show words as [\fB\-removed\-\fR] and {\fBadded\fR}\&. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous\&.
  661. .RE
  662. .PP
  663. \fBporcelain\fR
  664. .RS 4
  665. Use a special line\-based format intended for script consumption\&. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a
  666. \fB+\fR/\fB\-\fR/` ` character at the beginning of the line and extending to the end of the line\&. Newlines in the input are represented by a tilde
  667. \fB~\fR
  668. on a line of its own\&.
  669. .RE
  670. .PP
  671. \fBnone\fR
  672. .RS 4
  673. Disable word diff again\&.
  674. .RE
  675. .sp
  676. Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled\&.
  677. .RE
  678. .PP
  679. \fB\-\-word\-diff\-regex=\fR\fI<regex>\fR
  680. .RS 4
  681. Use
  682. \fI<regex>\fR
  683. to decide what a word is, instead of considering runs of non\-whitespace to be a word\&. Also implies
  684. \fB\-\-word\-diff\fR
  685. unless it was already enabled\&.
  686. .sp
  687. Every non\-overlapping match of the
  688. \fI<regex>\fR
  689. is considered a word\&. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences\&. You may want to append |[\fB^\fR[\fB:space:\fR]] to your regular expression to make sure that it matches all non\-whitespace characters\&. A match that contains a newline is silently truncated(!) at the newline\&.
  690. .sp
  691. For example,
  692. \fB\-\-word\-diff\-regex=\&.\fR
  693. will treat each character as a word and, correspondingly, show differences character by character\&.
  694. .sp
  695. The regex can also be set via a diff driver or configuration option, see
  696. \fBgitattributes\fR(5)
  697. or
  698. \fBgit-config\fR(1)\&. Giving it explicitly overrides any diff driver or configuration setting\&. Diff drivers override configuration settings\&.
  699. .RE
  700. .PP
  701. \fB\-\-color\-words\fR[\fB=\fR\fI<regex>\fR]
  702. .RS 4
  703. Equivalent to
  704. \fB\-\-word\-diff=color\fR
  705. plus (if a regex was specified)
  706. \fB\-\-word\-diff\-regex=\fR\fI<regex>\fR\&.
  707. .RE
  708. .PP
  709. \fB\-\-no\-renames\fR
  710. .RS 4
  711. Turn off rename detection, even when the configuration file gives the default to do so\&.
  712. .RE
  713. .PP
  714. \fB\-\-\fR[\fBno\-\fR]\fBrename\-empty\fR
  715. .RS 4
  716. Whether to use empty blobs as rename source\&.
  717. .RE
  718. .PP
  719. \fB\-\-check\fR
  720. .RS 4
  721. Warn if changes introduce conflict markers or whitespace errors\&. What are considered whitespace errors is controlled by
  722. \fBcore\&.whitespace\fR
  723. configuration\&. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors\&. Exits with non\-zero status if problems are found\&. Not compatible with
  724. \fB\-\-exit\-code\fR\&.
  725. .RE
  726. .PP
  727. \fB\-\-ws\-error\-highlight=\fR\fI<kind>\fR
  728. .RS 4
  729. Highlight whitespace errors in the
  730. \fBcontext\fR,
  731. \fBold\fR
  732. or
  733. \fBnew\fR
  734. lines of the diff\&. Multiple values are separated by comma,
  735. \fBnone\fR
  736. resets previous values,
  737. \fBdefault\fR
  738. reset the list to
  739. \fBnew\fR
  740. and
  741. \fBall\fR
  742. is a shorthand for
  743. \fBold,new,context\fR\&. When this option is not given, and the configuration variable
  744. \fBdiff\&.wsErrorHighlight\fR
  745. is not set, only whitespace errors in
  746. \fBnew\fR
  747. lines are highlighted\&. The whitespace errors are colored with
  748. \fBcolor\&.diff\&.whitespace\fR\&.
  749. .RE
  750. .PP
  751. \fB\-\-full\-index\fR
  752. .RS 4
  753. Instead of the first handful of characters, show the full pre\- and post\-image blob object names on the "index" line when generating patch format output\&.
  754. .RE
  755. .PP
  756. \fB\-\-binary\fR
  757. .RS 4
  758. In addition to
  759. \fB\-\-full\-index\fR, output a binary diff that can be applied with
  760. \fBgit\-apply\fR\&. Implies
  761. \fB\-\-patch\fR\&.
  762. .RE
  763. .PP
  764. \fB\-\-abbrev\fR[\fB=\fR\fI<n>\fR]
  765. .RS 4
  766. Instead of showing the full 40\-byte hexadecimal object name in diff\-raw format output and diff\-tree header lines, show the shortest prefix that is at least
  767. \fI<n>\fR
  768. hexdigits long that uniquely refers the object\&. In diff\-patch output format,
  769. \fB\-\-full\-index\fR
  770. takes higher precedence, i\&.e\&. if
  771. \fB\-\-full\-index\fR
  772. is specified, full blob names will be shown regardless of
  773. \fB\-\-abbrev\fR\&. Non default number of digits can be specified with
  774. \fB\-\-abbrev=\fR\fI<n>\fR\&.
  775. .RE
  776. .PP
  777. \fB\-B\fR[\fI<n>\fR][\fB/\fR\fI<m>\fR], \fB\-\-break\-rewrites\fR[\fB=\fR[\fI<n>\fR][\fB/\fR\fI<m>\fR]]
  778. .RS 4
  779. Break complete rewrite changes into pairs of delete and create\&. This serves two purposes:
  780. .sp
  781. It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number
  782. \fI<m>\fR
  783. controls this aspect of the
  784. \fB\-B\fR
  785. option (defaults to 60%)\&.
  786. \fB\-B/70\fR% specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i\&.e\&. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines)\&.
  787. .sp
  788. When used with
  789. \fB\-M\fR, a totally\-rewritten file is also considered as the source of a rename (usually
  790. \fB\-M\fR
  791. only considers a file that disappeared as the source of a rename), and the number
  792. \fI<n>\fR
  793. controls this aspect of the
  794. \fB\-B\fR
  795. option (defaults to 50%)\&.
  796. \fB\-B20\fR% specifies that a change with addition and deletion compared to 20% or more of the file\(cqs size are eligible for being picked up as a possible source of a rename to another file\&.
  797. .RE
  798. .PP
  799. \fB\-M\fR[\fI<n>\fR], \fB\-\-find\-renames\fR[\fB=\fR\fI<n>\fR]
  800. .RS 4
  801. Detect renames\&. If
  802. \fI<n>\fR
  803. is specified, it is a threshold on the similarity index (i\&.e\&. amount of addition/deletions compared to the file\(cqs size)\&. For example,
  804. \fB\-M90\fR% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn\(cqt changed\&. Without a % sign, the number is to be read as a fraction, with a decimal point before it\&. I\&.e\&.,
  805. \fB\-M5\fR
  806. becomes 0\&.5, and is thus the same as
  807. \fB\-M50\fR%\&. Similarly,
  808. \fB\-M05\fR
  809. is the same as
  810. \fB\-M5\fR%\&. To limit detection to exact renames, use
  811. \fB\-M100\fR%\&. The default similarity index is 50%\&.
  812. .RE
  813. .PP
  814. \fB\-C\fR[\fI<n>\fR], \fB\-\-find\-copies\fR[\fB=\fR\fI<n>\fR]
  815. .RS 4
  816. Detect copies as well as renames\&. See also
  817. \fB\-\-find\-copies\-harder\fR\&. If
  818. \fI<n>\fR
  819. is specified, it has the same meaning as for
  820. \fB\-M\fR\fI<n>\fR\&.
  821. .RE
  822. .PP
  823. \fB\-\-find\-copies\-harder\fR
  824. .RS 4
  825. For performance reasons, by default,
  826. \fB\-C\fR
  827. option finds copies only if the original file of the copy was modified in the same changeset\&. This flag makes the command inspect unmodified files as candidates for the source of copy\&. This is a very expensive operation for large projects, so use it with caution\&. Giving more than one
  828. \fB\-C\fR
  829. option has the same effect\&.
  830. .RE
  831. .PP
  832. \fB\-D\fR, \fB\-\-irreversible\-delete\fR
  833. .RS 4
  834. Omit the preimage for deletes, i\&.e\&. print only the header but not the diff between the preimage and
  835. \fB/dev/null\fR\&. The resulting patch is not meant to be applied with
  836. \fBpatch\fR
  837. or
  838. \fBgit\fR
  839. \fBapply\fR; this is solely for people who want to just concentrate on reviewing the text after the change\&. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option\&.
  840. .sp
  841. When used together with
  842. \fB\-B\fR, omit also the preimage in the deletion part of a delete/create pair\&.
  843. .RE
  844. .PP
  845. \fB\-l\fR\fI<num>\fR
  846. .RS 4
  847. The
  848. \fB\-M\fR
  849. and
  850. \fB\-C\fR
  851. options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources\&. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant\&.) For N sources and destinations, this exhaustive check is O(N^2)\&. This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number\&. Defaults to
  852. \fBdiff\&.renameLimit\fR\&. Note that a value of 0 is treated as unlimited\&.
  853. .RE
  854. .PP
  855. \fB\-\-diff\-filter=\fR[(\fBA\fR|\fBC\fR|\fBD\fR|\fBM\fR|\fBR\fR|\fBT\fR|\fBU\fR|\fBX\fR|\fBB\fR)\fB\&.\&.\&.\fR[*]]
  856. .RS 4
  857. Select only files that are Added (\fBA\fR), Copied (\fBC\fR), Deleted (\fBD\fR), Modified (\fBM\fR), Renamed (\fBR\fR), have their type (i\&.e\&. regular file, symlink, submodule, \&...\:) changed (\fBT\fR), are Unmerged (\fBU\fR), are Unknown (\fBX\fR), or have had their pairing Broken (\fBB\fR)\&. Any combination of the filter characters (including none) can be used\&. When * (All\-or\-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected\&.
  858. .sp
  859. Also, these upper\-case letters can be downcased to exclude\&. E\&.g\&.
  860. \fB\-\-diff\-filter=ad\fR
  861. excludes added and deleted paths\&.
  862. .sp
  863. Note that not all diffs can feature all types\&. For instance, copied and renamed entries cannot appear if detection for those types is disabled\&.
  864. .RE
  865. .PP
  866. \fB\-S\fR\fI<string>\fR
  867. .RS 4
  868. Look for differences that change the number of occurrences of the specified
  869. \fI<string>\fR
  870. (i\&.e\&. addition/deletion) in a file\&. Intended for the scripter\(cqs use\&.
  871. .sp
  872. It is useful when you\(cqre looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into
  873. \fB\-S\fR, and keep going until you get the very first version of the block\&.
  874. .sp
  875. Binary files are searched as well\&.
  876. .RE
  877. .PP
  878. \fB\-G\fR\fI<regex>\fR
  879. .RS 4
  880. Look for differences whose patch text contains added/removed lines that match
  881. \fI<regex>\fR\&.
  882. .sp
  883. To illustrate the difference between
  884. \fB\-S\fR\fI<regex>\fR
  885. \fB\-\-pickaxe\-regex\fR
  886. and
  887. \fB\-G\fR\fI<regex>\fR, consider a commit with the following diff in the same file:
  888. .sp
  889. .if n \{\
  890. .RS 4
  891. .\}
  892. .nf
  893. + return frotz(nitfol, two\->ptr, 1, 0);
  894. \&.\&.\&.
  895. \- hit = frotz(nitfol, mf2\&.ptr, 1, 0);
  896. .fi
  897. .if n \{\
  898. .RE
  899. .\}
  900. .sp
  901. While
  902. \fBgit\fR
  903. \fBlog\fR
  904. \fB\-G\fR"frotz\e(\fBnitfol\fR" will show this commit,
  905. \fBgit\fR
  906. \fBlog\fR
  907. \fB\-S\fR"frotz\e(\fBnitfol\fR"
  908. \fB\-\-pickaxe\-regex\fR
  909. will not (because the number of occurrences of that string did not change)\&.
  910. .sp
  911. Unless
  912. \fB\-\-text\fR
  913. is supplied patches of binary files without a textconv filter will be ignored\&.
  914. .sp
  915. See the
  916. \fIpickaxe\fR
  917. entry in
  918. \fBgitdiffcore\fR(7)
  919. for more information\&.
  920. .RE
  921. .PP
  922. \fB\-\-find\-object=\fR\fI<object\-id>\fR
  923. .RS 4
  924. Look for differences that change the number of occurrences of the specified object\&. Similar to
  925. \fB\-S\fR, just the argument is different in that it doesn\(cqt search for a specific string but for a specific object id\&.
  926. .sp
  927. The object can be a blob or a submodule commit\&. It implies the
  928. \fB\-t\fR
  929. option in
  930. \fBgit\-log\fR
  931. to also find trees\&.
  932. .RE
  933. .PP
  934. \fB\-\-pickaxe\-all\fR
  935. .RS 4
  936. When
  937. \fB\-S\fR
  938. or
  939. \fB\-G\fR
  940. finds a change, show all the changes in that changeset, not just the files that contain the change in
  941. \fI<string>\fR\&.
  942. .RE
  943. .PP
  944. \fB\-\-pickaxe\-regex\fR
  945. .RS 4
  946. Treat the
  947. \fI<string>\fR
  948. given to
  949. \fB\-S\fR
  950. as an extended POSIX regular expression to match\&.
  951. .RE
  952. .PP
  953. \fB\-O\fR\fI<orderfile>\fR
  954. .RS 4
  955. Control the order in which files appear in the output\&. This overrides the
  956. \fBdiff\&.orderFile\fR
  957. configuration variable (see
  958. \fBgit-config\fR(1))\&. To cancel
  959. \fBdiff\&.orderFile\fR, use
  960. \fB\-O/dev/null\fR\&.
  961. .sp
  962. The output order is determined by the order of glob patterns in
  963. \fI<orderfile>\fR\&. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on\&. All files with pathnames that do not match any pattern are output last, as if there was an implicit match\-all pattern at the end of the file\&. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order\&.
  964. .sp
  965. \fI<orderfile>\fR
  966. is parsed as follows:
  967. .sp
  968. .RS 4
  969. .ie n \{\
  970. \h'-04'\(bu\h'+03'\c
  971. .\}
  972. .el \{\
  973. .sp -1
  974. .IP \(bu 2.3
  975. .\}
  976. Blank lines are ignored, so they can be used as separators for readability\&.
  977. .RE
  978. .sp
  979. .RS 4
  980. .ie n \{\
  981. \h'-04'\(bu\h'+03'\c
  982. .\}
  983. .el \{\
  984. .sp -1
  985. .IP \(bu 2.3
  986. .\}
  987. Lines starting with a hash ("#") are ignored, so they can be used for comments\&. Add a backslash ("\e") to the beginning of the pattern if it starts with a hash\&.
  988. .RE
  989. .sp
  990. .RS 4
  991. .ie n \{\
  992. \h'-04'\(bu\h'+03'\c
  993. .\}
  994. .el \{\
  995. .sp -1
  996. .IP \(bu 2.3
  997. .\}
  998. Each other line contains a single pattern\&.
  999. .RE
  1000. .sp
  1001. Patterns have the same syntax and semantics as patterns used for
  1002. \fBfnmatch\fR(3) without the
  1003. \fBFNM_PATHNAME\fR
  1004. flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern\&. For example, the pattern "\fBfoo\fR*bar" matches "\fBfooasdfbar\fR" and "\fBfoo/bar/baz/asdf\fR" but not "\fBfoobarx\fR"\&.
  1005. .RE
  1006. .PP
  1007. \fB\-\-skip\-to=\fR\fI<file>\fR, \fB\-\-rotate\-to=\fR\fI<file>\fR
  1008. .RS 4
  1009. Discard the files before the named
  1010. \fI<file>\fR
  1011. from the output (i\&.e\&.
  1012. \fIskip to\fR), or move them to the end of the output (i\&.e\&.
  1013. \fIrotate to\fR)\&. These options were invented primarily for the use of the
  1014. \fBgit\fR
  1015. \fBdifftool\fR
  1016. command, and may not be very useful otherwise\&.
  1017. .RE
  1018. .PP
  1019. \fB\-R\fR
  1020. .RS 4
  1021. Swap two inputs; that is, show differences from index or on\-disk file to tree contents\&.
  1022. .RE
  1023. .PP
  1024. \fB\-\-relative\fR[\fB=\fR\fI<path>\fR], \fB\-\-no\-relative\fR
  1025. .RS 4
  1026. When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option\&. When you are not in a subdirectory (e\&.g\&. in a bare repository), you can name which subdirectory to make the output relative to by giving a
  1027. \fI<path>\fR
  1028. as an argument\&.
  1029. \fB\-\-no\-relative\fR
  1030. can be used to countermand both
  1031. \fBdiff\&.relative\fR
  1032. config option and previous
  1033. \fB\-\-relative\fR\&.
  1034. .RE
  1035. .PP
  1036. \fB\-a\fR, \fB\-\-text\fR
  1037. .RS 4
  1038. Treat all files as text\&.
  1039. .RE
  1040. .PP
  1041. \fB\-\-ignore\-cr\-at\-eol\fR
  1042. .RS 4
  1043. Ignore carriage\-return at the end of line when doing a comparison\&.
  1044. .RE
  1045. .PP
  1046. \fB\-\-ignore\-space\-at\-eol\fR
  1047. .RS 4
  1048. Ignore changes in whitespace at EOL\&.
  1049. .RE
  1050. .PP
  1051. \fB\-b\fR, \fB\-\-ignore\-space\-change\fR
  1052. .RS 4
  1053. Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
  1054. .RE
  1055. .PP
  1056. \fB\-w\fR, \fB\-\-ignore\-all\-space\fR
  1057. .RS 4
  1058. Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
  1059. .RE
  1060. .PP
  1061. \fB\-\-ignore\-blank\-lines\fR
  1062. .RS 4
  1063. Ignore changes whose lines are all blank\&.
  1064. .RE
  1065. .PP
  1066. \fB\-I\fR\fI<regex>\fR, \fB\-\-ignore\-matching\-lines=\fR\fI<regex>\fR
  1067. .RS 4
  1068. Ignore changes whose all lines match
  1069. \fI<regex>\fR\&. This option may be specified more than once\&.
  1070. .RE
  1071. .PP
  1072. \fB\-\-inter\-hunk\-context=\fR\fI<number>\fR
  1073. .RS 4
  1074. Show the context between diff hunks, up to the specified
  1075. \fI<number>\fR
  1076. of lines, thereby fusing hunks that are close to each other\&. Defaults to
  1077. \fBdiff\&.interHunkContext\fR
  1078. or 0 if the config option is unset\&.
  1079. .RE
  1080. .PP
  1081. \fB\-W\fR, \fB\-\-function\-context\fR
  1082. .RS 4
  1083. Show whole function as context lines for each change\&. The function names are determined in the same way as
  1084. \fBgit\fR
  1085. \fBdiff\fR
  1086. works out patch hunk headers (see "Defining a custom hunk\-header" in
  1087. \fBgitattributes\fR(5))\&.
  1088. .RE
  1089. .PP
  1090. \fB\-\-exit\-code\fR
  1091. .RS 4
  1092. Make the program exit with codes similar to
  1093. \fBdiff\fR(1)\&. That is, it exits with 1 if there were differences and 0 means no differences\&.
  1094. .RE
  1095. .PP
  1096. \fB\-\-quiet\fR
  1097. .RS 4
  1098. Disable all output of the program\&. Implies
  1099. \fB\-\-exit\-code\fR\&. Disables execution of external diff helpers whose exit code is not trusted, i\&.e\&. their respective configuration option
  1100. \fBdiff\&.trustExitCode\fR
  1101. or
  1102. \fBdiff\&.\fR\fI<driver>\fR\&.\fBtrustExitCode\fR
  1103. or environment variable
  1104. \fBGIT_EXTERNAL_DIFF_TRUST_EXIT_CODE\fR
  1105. is false\&.
  1106. .RE
  1107. .PP
  1108. \fB\-\-ext\-diff\fR
  1109. .RS 4
  1110. Allow an external diff helper to be executed\&. If you set an external diff driver with
  1111. \fBgitattributes\fR(5), you need to use this option with
  1112. \fBgit-log\fR(1)
  1113. and friends\&.
  1114. .RE
  1115. .PP
  1116. \fB\-\-no\-ext\-diff\fR
  1117. .RS 4
  1118. Disallow external diff drivers\&.
  1119. .RE
  1120. .PP
  1121. \fB\-\-textconv\fR, \fB\-\-no\-textconv\fR
  1122. .RS 4
  1123. Allow (or disallow) external text conversion filters to be run when comparing binary files\&. See
  1124. \fBgitattributes\fR(5)
  1125. for details\&. Because textconv filters are typically a one\-way conversion, the resulting diff is suitable for human consumption, but cannot be applied\&. For this reason, textconv filters are enabled by default only for
  1126. \fBgit-diff\fR(1)
  1127. and
  1128. \fBgit-log\fR(1), but not for
  1129. \fBgit-format-patch\fR(1)
  1130. or diff plumbing commands\&.
  1131. .RE
  1132. .PP
  1133. \fB\-\-ignore\-submodules\fR[\fB=\fR(\fBnone\fR|\fBuntracked\fR|\fBdirty\fR|\fBall\fR)]
  1134. .RS 4
  1135. Ignore changes to submodules in the diff generation\&.
  1136. \fBall\fR
  1137. is the default\&. Using
  1138. \fBnone\fR
  1139. will consider the submodule modified when it either contains untracked or modified files or its
  1140. \fBHEAD\fR
  1141. differs from the commit recorded in the superproject and can be used to override any settings of the
  1142. \fBignore\fR
  1143. option in
  1144. \fBgit-config\fR(1)
  1145. or
  1146. \fBgitmodules\fR(5)\&. When
  1147. \fBuntracked\fR
  1148. is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content)\&. Using
  1149. \fBdirty\fR
  1150. ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1\&.7\&.0)\&. Using
  1151. \fBall\fR
  1152. hides all changes to submodules\&.
  1153. .RE
  1154. .PP
  1155. \fB\-\-src\-prefix=\fR\fI<prefix>\fR
  1156. .RS 4
  1157. Show the given source
  1158. \fI<prefix>\fR
  1159. instead of "a/"\&.
  1160. .RE
  1161. .PP
  1162. \fB\-\-dst\-prefix=\fR\fI<prefix>\fR
  1163. .RS 4
  1164. Show the given destination
  1165. \fI<prefix>\fR
  1166. instead of "b/"\&.
  1167. .RE
  1168. .PP
  1169. \fB\-\-no\-prefix\fR
  1170. .RS 4
  1171. Do not show any source or destination prefix\&.
  1172. .RE
  1173. .PP
  1174. \fB\-\-default\-prefix\fR
  1175. .RS 4
  1176. Use the default source and destination prefixes ("a/" and "b/")\&. This overrides configuration variables such as
  1177. \fBdiff\&.noprefix\fR,
  1178. \fBdiff\&.srcPrefix\fR,
  1179. \fBdiff\&.dstPrefix\fR, and
  1180. \fBdiff\&.mnemonicPrefix\fR
  1181. (see
  1182. \fBgit-config\fR(1))\&.
  1183. .RE
  1184. .PP
  1185. \fB\-\-line\-prefix=\fR\fI<prefix>\fR
  1186. .RS 4
  1187. Prepend an additional
  1188. \fI<prefix>\fR
  1189. to every line of output\&.
  1190. .RE
  1191. .PP
  1192. \fB\-\-ita\-invisible\-in\-index\fR
  1193. .RS 4
  1194. By default entries added by
  1195. \fBgit\fR
  1196. \fBadd\fR
  1197. \fB\-N\fR
  1198. appear as an existing empty file in
  1199. \fBgit\fR
  1200. \fBdiff\fR
  1201. and a new file in
  1202. \fBgit\fR
  1203. \fBdiff\fR
  1204. \fB\-\-cached\fR\&. This option makes the entry appear as a new file in
  1205. \fBgit\fR
  1206. \fBdiff\fR
  1207. and non\-existent in
  1208. \fBgit\fR
  1209. \fBdiff\fR
  1210. \fB\-\-cached\fR\&. This option could be reverted with
  1211. \fB\-\-ita\-visible\-in\-index\fR\&. Both options are experimental and could be removed in future\&.
  1212. .RE
  1213. .sp
  1214. For more detailed explanation on these common options, see also \fBgitdiffcore\fR(7)\&.
  1215. .PP
  1216. \fB\-1\fR, \fB\-\-base\fR, \fB\-2\fR, \fB\-\-ours\fR, \fB\-3\fR, \fB\-\-theirs\fR
  1217. .RS 4
  1218. Compare the working tree with
  1219. .sp
  1220. .RS 4
  1221. .ie n \{\
  1222. \h'-04'\(bu\h'+03'\c
  1223. .\}
  1224. .el \{\
  1225. .sp -1
  1226. .IP \(bu 2.3
  1227. .\}
  1228. the "base" version (stage #1) when using
  1229. \fB\-1\fR
  1230. or
  1231. \fB\-\-base\fR,
  1232. .RE
  1233. .sp
  1234. .RS 4
  1235. .ie n \{\
  1236. \h'-04'\(bu\h'+03'\c
  1237. .\}
  1238. .el \{\
  1239. .sp -1
  1240. .IP \(bu 2.3
  1241. .\}
  1242. "our branch" (stage #2) when using
  1243. \fB\-2\fR
  1244. or
  1245. \fB\-\-ours\fR, or
  1246. .RE
  1247. .sp
  1248. .RS 4
  1249. .ie n \{\
  1250. \h'-04'\(bu\h'+03'\c
  1251. .\}
  1252. .el \{\
  1253. .sp -1
  1254. .IP \(bu 2.3
  1255. .\}
  1256. "their branch" (stage #3) when using
  1257. \fB\-3\fR
  1258. or
  1259. \fB\-\-theirs\fR\&.
  1260. .RE
  1261. .sp
  1262. The index contains these stages only for unmerged entries i\&.e\&. while resolving conflicts\&. See
  1263. \fBgit-read-tree\fR(1)
  1264. section "3\-Way Merge" for detailed information\&.
  1265. .RE
  1266. .PP
  1267. \fB\-0\fR
  1268. .RS 4
  1269. Omit diff output for unmerged entries and just show "Unmerged"\&. Can be used only when comparing the working tree with the index\&.
  1270. .RE
  1271. .PP
  1272. \fI<path>\fR\&.\&.\&.
  1273. .RS 4
  1274. The
  1275. \fI<path>\fR
  1276. 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)\&.
  1277. .RE
  1278. .SH "RAW OUTPUT FORMAT"
  1279. .sp
  1280. The raw output format from \fBgit\-diff\-index\fR, \fBgit\-diff\-tree\fR, \fBgit\-diff\-files\fR and \fBgit\fR \fBdiff\fR \fB\-\-raw\fR are very similar\&.
  1281. .sp
  1282. These commands all compare two sets of things; what is compared differs:
  1283. .PP
  1284. \fBgit\-diff\-index\fR \fI<tree\-ish>\fR
  1285. .RS 4
  1286. compares the
  1287. \fI<tree\-ish>\fR
  1288. and the files on the filesystem\&.
  1289. .RE
  1290. .PP
  1291. \fBgit\-diff\-index\fR \fB\-\-cached\fR \fI<tree\-ish>\fR
  1292. .RS 4
  1293. compares the
  1294. \fI<tree\-ish>\fR
  1295. and the index\&.
  1296. .RE
  1297. .PP
  1298. \fBgit\-diff\-tree\fR [\fB\-r\fR] \fI<tree\-ish\-1>\fR \fI<tree\-ish\-2>\fR [\fI<pattern>\fR\&.\&.\&.]
  1299. .RS 4
  1300. compares the trees named by the two arguments\&.
  1301. .RE
  1302. .PP
  1303. \fBgit\-diff\-files\fR [\fI<pattern>\fR\&.\&.\&.]
  1304. .RS 4
  1305. compares the index and the files on the filesystem\&.
  1306. .RE
  1307. .sp
  1308. The \fBgit\-diff\-tree\fR command begins its output by printing the hash of what is being compared\&. After that, all the commands print one output line per changed file\&.
  1309. .sp
  1310. An output line is formatted this way:
  1311. .sp
  1312. .if n \{\
  1313. .RS 4
  1314. .\}
  1315. .nf
  1316. in\-place edit :100644 100644 bcd1234 0123456 M file0
  1317. copy\-edit :100644 100644 abcd123 1234567 C68 file1 file2
  1318. rename\-edit :100644 100644 abcd123 1234567 R86 file1 file3
  1319. create :000000 100644 0000000 1234567 A file4
  1320. delete :100644 000000 1234567 0000000 D file5
  1321. unmerged :000000 000000 0000000 0000000 U file6
  1322. .fi
  1323. .if n \{\
  1324. .RE
  1325. .\}
  1326. .sp
  1327. That is, from the left to the right:
  1328. .sp
  1329. .RS 4
  1330. .ie n \{\
  1331. \h'-04' 1.\h'+01'\c
  1332. .\}
  1333. .el \{\
  1334. .sp -1
  1335. .IP " 1." 4.2
  1336. .\}
  1337. a colon\&.
  1338. .RE
  1339. .sp
  1340. .RS 4
  1341. .ie n \{\
  1342. \h'-04' 2.\h'+01'\c
  1343. .\}
  1344. .el \{\
  1345. .sp -1
  1346. .IP " 2." 4.2
  1347. .\}
  1348. mode for "src"; 000000 if creation or unmerged\&.
  1349. .RE
  1350. .sp
  1351. .RS 4
  1352. .ie n \{\
  1353. \h'-04' 3.\h'+01'\c
  1354. .\}
  1355. .el \{\
  1356. .sp -1
  1357. .IP " 3." 4.2
  1358. .\}
  1359. a space\&.
  1360. .RE
  1361. .sp
  1362. .RS 4
  1363. .ie n \{\
  1364. \h'-04' 4.\h'+01'\c
  1365. .\}
  1366. .el \{\
  1367. .sp -1
  1368. .IP " 4." 4.2
  1369. .\}
  1370. mode for "dst"; 000000 if deletion or unmerged\&.
  1371. .RE
  1372. .sp
  1373. .RS 4
  1374. .ie n \{\
  1375. \h'-04' 5.\h'+01'\c
  1376. .\}
  1377. .el \{\
  1378. .sp -1
  1379. .IP " 5." 4.2
  1380. .\}
  1381. a space\&.
  1382. .RE
  1383. .sp
  1384. .RS 4
  1385. .ie n \{\
  1386. \h'-04' 6.\h'+01'\c
  1387. .\}
  1388. .el \{\
  1389. .sp -1
  1390. .IP " 6." 4.2
  1391. .\}
  1392. sha1 for "src"; 0{40} if creation or unmerged\&.
  1393. .RE
  1394. .sp
  1395. .RS 4
  1396. .ie n \{\
  1397. \h'-04' 7.\h'+01'\c
  1398. .\}
  1399. .el \{\
  1400. .sp -1
  1401. .IP " 7." 4.2
  1402. .\}
  1403. a space\&.
  1404. .RE
  1405. .sp
  1406. .RS 4
  1407. .ie n \{\
  1408. \h'-04' 8.\h'+01'\c
  1409. .\}
  1410. .el \{\
  1411. .sp -1
  1412. .IP " 8." 4.2
  1413. .\}
  1414. sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index"\&.
  1415. .RE
  1416. .sp
  1417. .RS 4
  1418. .ie n \{\
  1419. \h'-04' 9.\h'+01'\c
  1420. .\}
  1421. .el \{\
  1422. .sp -1
  1423. .IP " 9." 4.2
  1424. .\}
  1425. a space\&.
  1426. .RE
  1427. .sp
  1428. .RS 4
  1429. .ie n \{\
  1430. \h'-04'10.\h'+01'\c
  1431. .\}
  1432. .el \{\
  1433. .sp -1
  1434. .IP "10." 4.2
  1435. .\}
  1436. status, followed by optional "score" number\&.
  1437. .RE
  1438. .sp
  1439. .RS 4
  1440. .ie n \{\
  1441. \h'-04'11.\h'+01'\c
  1442. .\}
  1443. .el \{\
  1444. .sp -1
  1445. .IP "11." 4.2
  1446. .\}
  1447. a tab or a NUL when
  1448. \fB\-z\fR
  1449. option is used\&.
  1450. .RE
  1451. .sp
  1452. .RS 4
  1453. .ie n \{\
  1454. \h'-04'12.\h'+01'\c
  1455. .\}
  1456. .el \{\
  1457. .sp -1
  1458. .IP "12." 4.2
  1459. .\}
  1460. path for "src"
  1461. .RE
  1462. .sp
  1463. .RS 4
  1464. .ie n \{\
  1465. \h'-04'13.\h'+01'\c
  1466. .\}
  1467. .el \{\
  1468. .sp -1
  1469. .IP "13." 4.2
  1470. .\}
  1471. a tab or a NUL when
  1472. \fB\-z\fR
  1473. option is used; only exists for C or R\&.
  1474. .RE
  1475. .sp
  1476. .RS 4
  1477. .ie n \{\
  1478. \h'-04'14.\h'+01'\c
  1479. .\}
  1480. .el \{\
  1481. .sp -1
  1482. .IP "14." 4.2
  1483. .\}
  1484. path for "dst"; only exists for C or R\&.
  1485. .RE
  1486. .sp
  1487. .RS 4
  1488. .ie n \{\
  1489. \h'-04'15.\h'+01'\c
  1490. .\}
  1491. .el \{\
  1492. .sp -1
  1493. .IP "15." 4.2
  1494. .\}
  1495. an LF or a NUL when
  1496. \fB\-z\fR
  1497. option is used, to terminate the record\&.
  1498. .RE
  1499. .sp
  1500. Possible status letters are:
  1501. .sp
  1502. .RS 4
  1503. .ie n \{\
  1504. \h'-04'\(bu\h'+03'\c
  1505. .\}
  1506. .el \{\
  1507. .sp -1
  1508. .IP \(bu 2.3
  1509. .\}
  1510. \fBA\fR: addition of a file
  1511. .RE
  1512. .sp
  1513. .RS 4
  1514. .ie n \{\
  1515. \h'-04'\(bu\h'+03'\c
  1516. .\}
  1517. .el \{\
  1518. .sp -1
  1519. .IP \(bu 2.3
  1520. .\}
  1521. \fBC\fR: copy of a file into a new one
  1522. .RE
  1523. .sp
  1524. .RS 4
  1525. .ie n \{\
  1526. \h'-04'\(bu\h'+03'\c
  1527. .\}
  1528. .el \{\
  1529. .sp -1
  1530. .IP \(bu 2.3
  1531. .\}
  1532. \fBD\fR: deletion of a file
  1533. .RE
  1534. .sp
  1535. .RS 4
  1536. .ie n \{\
  1537. \h'-04'\(bu\h'+03'\c
  1538. .\}
  1539. .el \{\
  1540. .sp -1
  1541. .IP \(bu 2.3
  1542. .\}
  1543. \fBM\fR: modification of the contents or mode of a file
  1544. .RE
  1545. .sp
  1546. .RS 4
  1547. .ie n \{\
  1548. \h'-04'\(bu\h'+03'\c
  1549. .\}
  1550. .el \{\
  1551. .sp -1
  1552. .IP \(bu 2.3
  1553. .\}
  1554. \fBR\fR: renaming of a file
  1555. .RE
  1556. .sp
  1557. .RS 4
  1558. .ie n \{\
  1559. \h'-04'\(bu\h'+03'\c
  1560. .\}
  1561. .el \{\
  1562. .sp -1
  1563. .IP \(bu 2.3
  1564. .\}
  1565. \fBT\fR: change in the type of the file (regular file, symbolic link or submodule)
  1566. .RE
  1567. .sp
  1568. .RS 4
  1569. .ie n \{\
  1570. \h'-04'\(bu\h'+03'\c
  1571. .\}
  1572. .el \{\
  1573. .sp -1
  1574. .IP \(bu 2.3
  1575. .\}
  1576. \fBU\fR: file is unmerged (you must complete the merge before it can be committed)
  1577. .RE
  1578. .sp
  1579. .RS 4
  1580. .ie n \{\
  1581. \h'-04'\(bu\h'+03'\c
  1582. .\}
  1583. .el \{\
  1584. .sp -1
  1585. .IP \(bu 2.3
  1586. .\}
  1587. \fBX\fR: "unknown" change type (most probably a bug, please report it)
  1588. .RE
  1589. .sp
  1590. Status letters \fBC\fR and \fBR\fR are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy)\&. Status letter \fBM\fR may be followed by a score (denoting the percentage of dissimilarity) for file rewrites\&.
  1591. .sp
  1592. The sha1 for "dst" is shown as all 0\(cqs if a file on the filesystem is out of sync with the index\&.
  1593. .sp
  1594. Example:
  1595. .sp
  1596. .if n \{\
  1597. .RS 4
  1598. .\}
  1599. .nf
  1600. :100644 100644 5be4a4a 0000000 M file\&.c
  1601. .fi
  1602. .if n \{\
  1603. .RE
  1604. .\}
  1605. .sp
  1606. Without the \fB\-z\fR option, pathnames with "unusual" characters are quoted as explained for the configuration variable \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. Using \fB\-z\fR the filename is output verbatim and the line is terminated by a NUL byte\&.
  1607. .SH "DIFF FORMAT FOR MERGES"
  1608. .sp
  1609. \fBgit\-diff\-tree\fR, \fBgit\-diff\-files\fR and \fBgit\-diff\fR \fB\-\-raw\fR can take \fB\-c\fR or \fB\-\-cc\fR option to generate diff output also for merge commits\&. The output differs from the format described above in the following way:
  1610. .sp
  1611. .RS 4
  1612. .ie n \{\
  1613. \h'-04' 1.\h'+01'\c
  1614. .\}
  1615. .el \{\
  1616. .sp -1
  1617. .IP " 1." 4.2
  1618. .\}
  1619. there is a colon for each parent
  1620. .RE
  1621. .sp
  1622. .RS 4
  1623. .ie n \{\
  1624. \h'-04' 2.\h'+01'\c
  1625. .\}
  1626. .el \{\
  1627. .sp -1
  1628. .IP " 2." 4.2
  1629. .\}
  1630. there are more "src" modes and "src" sha1
  1631. .RE
  1632. .sp
  1633. .RS 4
  1634. .ie n \{\
  1635. \h'-04' 3.\h'+01'\c
  1636. .\}
  1637. .el \{\
  1638. .sp -1
  1639. .IP " 3." 4.2
  1640. .\}
  1641. status is concatenated status characters for each parent
  1642. .RE
  1643. .sp
  1644. .RS 4
  1645. .ie n \{\
  1646. \h'-04' 4.\h'+01'\c
  1647. .\}
  1648. .el \{\
  1649. .sp -1
  1650. .IP " 4." 4.2
  1651. .\}
  1652. no optional "score" number
  1653. .RE
  1654. .sp
  1655. .RS 4
  1656. .ie n \{\
  1657. \h'-04' 5.\h'+01'\c
  1658. .\}
  1659. .el \{\
  1660. .sp -1
  1661. .IP " 5." 4.2
  1662. .\}
  1663. tab\-separated pathname(s) of the file
  1664. .RE
  1665. .sp
  1666. For \fB\-c\fR and \fB\-\-cc\fR, only the destination or final path is shown even if the file was renamed on any side of history\&. With \fB\-\-combined\-all\-paths\fR, the name of the path in each parent is shown followed by the name of the path in the merge commit\&.
  1667. .sp
  1668. Examples for \fB\-c\fR and \fB\-\-cc\fR without \fB\-\-combined\-all\-paths\fR:
  1669. .sp
  1670. .if n \{\
  1671. .RS 4
  1672. .\}
  1673. .nf
  1674. ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc\&.c
  1675. ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar\&.sh
  1676. ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey\&.c
  1677. .fi
  1678. .if n \{\
  1679. .RE
  1680. .\}
  1681. .sp
  1682. Examples when \fB\-\-combined\-all\-paths\fR added to either \fB\-c\fR or \fB\-\-cc\fR:
  1683. .sp
  1684. .if n \{\
  1685. .RS 4
  1686. .\}
  1687. .nf
  1688. ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc\&.c desc\&.c desc\&.c
  1689. ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo\&.sh bar\&.sh bar\&.sh
  1690. ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey\&.c fuey\&.c phooey\&.c
  1691. .fi
  1692. .if n \{\
  1693. .RE
  1694. .\}
  1695. .sp
  1696. Note that \fIcombined diff\fR lists only files which were modified from all parents\&.
  1697. .SH "GENERATING PATCH TEXT WITH \-P"
  1698. .sp
  1699. Running \fBgit-diff\fR(1), \fBgit-log\fR(1), \fBgit-show\fR(1), \fBgit-diff-index\fR(1), \fBgit-diff-tree\fR(1), or \fBgit-diff-files\fR(1) with the \fB\-p\fR option produces patch text\&. You can customize the creation of patch text via the \fBGIT_EXTERNAL_DIFF\fR and the \fBGIT_DIFF_OPTS\fR environment variables (see \fBgit\fR(1)), and the \fBdiff\fR attribute (see \fBgitattributes\fR(5))\&.
  1700. .sp
  1701. What the \fB\-p\fR option produces is slightly different from the traditional diff format:
  1702. .sp
  1703. .RS 4
  1704. .ie n \{\
  1705. \h'-04' 1.\h'+01'\c
  1706. .\}
  1707. .el \{\
  1708. .sp -1
  1709. .IP " 1." 4.2
  1710. .\}
  1711. It is preceded by a "git diff" header that looks like this:
  1712. .sp
  1713. .if n \{\
  1714. .RS 4
  1715. .\}
  1716. .nf
  1717. diff \-\-git a/file1 b/file2
  1718. .fi
  1719. .if n \{\
  1720. .RE
  1721. .\}
  1722. .sp
  1723. The
  1724. \fBa/\fR
  1725. and
  1726. \fBb/\fR
  1727. filenames are the same unless rename/copy is involved\&. Especially, even for a creation or a deletion,
  1728. \fB/dev/null\fR
  1729. is
  1730. \fInot\fR
  1731. used in place of the
  1732. \fBa/\fR
  1733. or
  1734. \fBb/\fR
  1735. filenames\&.
  1736. .sp
  1737. When a rename/copy is involved,
  1738. \fBfile1\fR
  1739. and
  1740. \fBfile2\fR
  1741. show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively\&.
  1742. .RE
  1743. .sp
  1744. .RS 4
  1745. .ie n \{\
  1746. \h'-04' 2.\h'+01'\c
  1747. .\}
  1748. .el \{\
  1749. .sp -1
  1750. .IP " 2." 4.2
  1751. .\}
  1752. It is followed by one or more extended header lines:
  1753. .sp
  1754. .if n \{\
  1755. .RS 4
  1756. .\}
  1757. .nf
  1758. \fBold\fR \fBmode\fR \fI<mode>\fR
  1759. \fBnew\fR \fBmode\fR \fI<mode>\fR
  1760. \fBdeleted\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
  1761. \fBnew\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
  1762. \fBcopy\fR \fBfrom\fR \fI<path>\fR
  1763. \fBcopy\fR \fBto\fR \fI<path>\fR
  1764. \fBrename\fR \fBfrom\fR \fI<path>\fR
  1765. \fBrename\fR \fBto\fR \fI<path>\fR
  1766. \fBsimilarity\fR \fBindex\fR \fI<number>\fR
  1767. \fBdissimilarity\fR \fBindex\fR \fI<number>\fR
  1768. \fBindex\fR \fI<hash>\fR`\&.\&.`\fI<hash>\fR \fI<mode>\fR
  1769. .fi
  1770. .if n \{\
  1771. .RE
  1772. .\}
  1773. File modes
  1774. \fI<mode>\fR
  1775. are printed as 6\-digit octal numbers including the file type and file permission bits\&.
  1776. .sp
  1777. Path names in extended headers do not include the
  1778. \fBa/\fR
  1779. and
  1780. \fBb/\fR
  1781. prefixes\&.
  1782. .sp
  1783. The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines\&. It is a rounded down integer, followed by a percent sign\&. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one\&.
  1784. .sp
  1785. The index line includes the blob object names before and after the change\&. The
  1786. \fI<mode>\fR
  1787. is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode\&.
  1788. .RE
  1789. .sp
  1790. .RS 4
  1791. .ie n \{\
  1792. \h'-04' 3.\h'+01'\c
  1793. .\}
  1794. .el \{\
  1795. .sp -1
  1796. .IP " 3." 4.2
  1797. .\}
  1798. Pathnames with "unusual" characters are quoted as explained for the configuration variable
  1799. \fBcore\&.quotePath\fR
  1800. (see
  1801. \fBgit-config\fR(1))\&.
  1802. .RE
  1803. .sp
  1804. .RS 4
  1805. .ie n \{\
  1806. \h'-04' 4.\h'+01'\c
  1807. .\}
  1808. .el \{\
  1809. .sp -1
  1810. .IP " 4." 4.2
  1811. .\}
  1812. All the
  1813. \fBfile1\fR
  1814. files in the output refer to files before the commit, and all the
  1815. \fBfile2\fR
  1816. files refer to files after the commit\&. It is incorrect to apply each change to each file sequentially\&. For example, this patch will swap a and b:
  1817. .sp
  1818. .if n \{\
  1819. .RS 4
  1820. .\}
  1821. .nf
  1822. diff \-\-git a/a b/b
  1823. rename from a
  1824. rename to b
  1825. diff \-\-git a/b b/a
  1826. rename from b
  1827. rename to a
  1828. .fi
  1829. .if n \{\
  1830. .RE
  1831. .\}
  1832. .RE
  1833. .sp
  1834. .RS 4
  1835. .ie n \{\
  1836. \h'-04' 5.\h'+01'\c
  1837. .\}
  1838. .el \{\
  1839. .sp -1
  1840. .IP " 5." 4.2
  1841. .\}
  1842. Hunk headers mention the name of the function to which the hunk applies\&. See "Defining a custom hunk\-header" in
  1843. \fBgitattributes\fR(5)
  1844. for details of how to tailor this to specific languages\&.
  1845. .RE
  1846. .SH "COMBINED DIFF FORMAT"
  1847. .sp
  1848. Any diff\-generating command can take the \fB\-c\fR or \fB\-\-cc\fR option to produce a \fIcombined diff\fR when showing a merge\&. This is the default format when showing merges with \fBgit-diff\fR(1) or \fBgit-show\fR(1)\&. Note also that you can give suitable \fB\-\-diff\-merges\fR option to any of these commands to force generation of diffs in a specific format\&.
  1849. .sp
  1850. A "combined diff" format looks like this:
  1851. .sp
  1852. .if n \{\
  1853. .RS 4
  1854. .\}
  1855. .nf
  1856. diff \-\-combined describe\&.c
  1857. index fabadb8,cc95eb0\&.\&.4866510
  1858. \-\-\- a/describe\&.c
  1859. +++ b/describe\&.c
  1860. @@@ \-98,20 \-98,12 +98,20 @@@
  1861. return (a_date > b_date) ? \-1 : (a_date == b_date) ? 0 : 1;
  1862. }
  1863. \- static void describe(char *arg)
  1864. \-static void describe(struct commit *cmit, int last_one)
  1865. ++static void describe(char *arg, int last_one)
  1866. {
  1867. + unsigned char sha1[20];
  1868. + struct commit *cmit;
  1869. struct commit_list *list;
  1870. static int initialized = 0;
  1871. struct commit_name *n;
  1872. + if (get_sha1(arg, sha1) < 0)
  1873. + usage(describe_usage);
  1874. + cmit = lookup_commit_reference(sha1);
  1875. + if (!cmit)
  1876. + usage(describe_usage);
  1877. +
  1878. if (!initialized) {
  1879. initialized = 1;
  1880. for_each_ref(get_name);
  1881. .fi
  1882. .if n \{\
  1883. .RE
  1884. .\}
  1885. .sp
  1886. .RS 4
  1887. .ie n \{\
  1888. \h'-04' 1.\h'+01'\c
  1889. .\}
  1890. .el \{\
  1891. .sp -1
  1892. .IP " 1." 4.2
  1893. .\}
  1894. It is preceded by a "git diff" header, that looks like this (when the
  1895. \fB\-c\fR
  1896. option is used):
  1897. .sp
  1898. .if n \{\
  1899. .RS 4
  1900. .\}
  1901. .nf
  1902. diff \-\-combined file
  1903. .fi
  1904. .if n \{\
  1905. .RE
  1906. .\}
  1907. .sp
  1908. or like this (when the
  1909. \fB\-\-cc\fR
  1910. option is used):
  1911. .sp
  1912. .if n \{\
  1913. .RS 4
  1914. .\}
  1915. .nf
  1916. diff \-\-cc file
  1917. .fi
  1918. .if n \{\
  1919. .RE
  1920. .\}
  1921. .RE
  1922. .sp
  1923. .RS 4
  1924. .ie n \{\
  1925. \h'-04' 2.\h'+01'\c
  1926. .\}
  1927. .el \{\
  1928. .sp -1
  1929. .IP " 2." 4.2
  1930. .\}
  1931. It is followed by one or more extended header lines (this example shows a merge with two parents):
  1932. .sp
  1933. .if n \{\
  1934. .RS 4
  1935. .\}
  1936. .nf
  1937. \fBindex\fR \fI<hash>\fR\fB,\fR\fI<hash>\fR`\&.\&.\fB__\fR\fI<hash>\fR\fB__\fR
  1938. {empty}`mode \fI<mode>\fR\fB,\fR\fI<mode>\fR``\&.\&.``\fI<mode>\fR
  1939. \fBnew\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
  1940. \fBdeleted\fR \fBfile\fR \fBmode\fR \fI<mode>\fR\fB,\fR\fI<mode>\fR
  1941. .fi
  1942. .if n \{\
  1943. .RE
  1944. .\}
  1945. The
  1946. \fBmode\fR
  1947. \fI<mode>\fR\fB,\fR\fI<mode>\fR\fB\&.\&.\fR\fI<mode>\fR
  1948. line appears only if at least one of the <mode> is different from the rest\&. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two
  1949. \fI<tree\-ish>\fR
  1950. and are not used by combined diff format\&.
  1951. .RE
  1952. .sp
  1953. .RS 4
  1954. .ie n \{\
  1955. \h'-04' 3.\h'+01'\c
  1956. .\}
  1957. .el \{\
  1958. .sp -1
  1959. .IP " 3." 4.2
  1960. .\}
  1961. It is followed by a two\-line from\-file/to\-file header:
  1962. .sp
  1963. .if n \{\
  1964. .RS 4
  1965. .\}
  1966. .nf
  1967. \-\-\- a/file
  1968. +++ b/file
  1969. .fi
  1970. .if n \{\
  1971. .RE
  1972. .\}
  1973. .sp
  1974. Similar to the two\-line header for the traditional
  1975. \fIunified\fR
  1976. diff format,
  1977. \fB/dev/null\fR
  1978. is used to signal created or deleted files\&.
  1979. .sp
  1980. However, if the \-\-combined\-all\-paths option is provided, instead of a two\-line from\-file/to\-file, you get an N+1 line from\-file/to\-file header, where N is the number of parents in the merge commit:
  1981. .sp
  1982. .if n \{\
  1983. .RS 4
  1984. .\}
  1985. .nf
  1986. \-\-\- a/file
  1987. \-\-\- a/file
  1988. \-\-\- a/file
  1989. +++ b/file
  1990. .fi
  1991. .if n \{\
  1992. .RE
  1993. .\}
  1994. .sp
  1995. This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents\&.
  1996. .RE
  1997. .sp
  1998. .RS 4
  1999. .ie n \{\
  2000. \h'-04' 4.\h'+01'\c
  2001. .\}
  2002. .el \{\
  2003. .sp -1
  2004. .IP " 4." 4.2
  2005. .\}
  2006. Chunk header format is modified to prevent people from accidentally feeding it to
  2007. \fBpatch\fR
  2008. \fB\-p1\fR\&. Combined diff format was created for review of merge commit changes, and was not meant to be applied\&. The change is similar to the change in the extended
  2009. \fIindex\fR
  2010. header:
  2011. .sp
  2012. .if n \{\
  2013. .RS 4
  2014. .\}
  2015. .nf
  2016. @@@ <from\-file\-range> <from\-file\-range> <to\-file\-range> @@@
  2017. .fi
  2018. .if n \{\
  2019. .RE
  2020. .\}
  2021. .sp
  2022. There are (number of parents + 1)
  2023. \fB@\fR
  2024. characters in the chunk header for combined diff format\&.
  2025. .RE
  2026. .sp
  2027. Unlike the traditional \fIunified\fR diff format, which shows two files A and B with a single column that has \fB\-\fR (minus \(em appears in A but removed in B), \fB+\fR (plus \(em missing in A but added to B), or " " (space \(em unchanged) prefix, this format compares two or more files file1, file2,\&...\: with one file X, and shows how X differs from each of fileN\&. One column for each of fileN is prepended to the output line to note how X\(cqs line is different from it\&.
  2028. .sp
  2029. A \fB\-\fR character in the column N means that the line appears in fileN but it does not appear in the result\&. A \fB+\fR character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent)\&.
  2030. .sp
  2031. In the above example output, the function signature was changed from both files (hence two \fB\-\fR removals from both file1 and file2, plus \fB++\fR to mean one line that was added does not appear in either file1 or file2)\&. Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with \fB+\fR)\&.
  2032. .sp
  2033. When shown by \fBgit\fR \fBdiff\-tree\fR \fB\-c\fR, it compares the parents of a merge commit with the merge result (i\&.e\&. file1\&.\&.fileN are the parents)\&. When shown by \fBgit\fR \fBdiff\-files\fR \fB\-c\fR, it compares the two unresolved merge parents with the working tree file (i\&.e\&. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version")\&.
  2034. .SH "OTHER DIFF FORMATS"
  2035. .sp
  2036. The \fB\-\-summary\fR option describes newly added, deleted, renamed and copied files\&. The \fB\-\-stat\fR option adds \fBdiffstat\fR(1) graph to the output\&. These options can be combined with other options, such as \fB\-p\fR, and are meant for human consumption\&.
  2037. .sp
  2038. When showing a change that involves a rename or a copy, \fB\-\-stat\fR output formats the pathnames compactly by combining common prefix and suffix of the pathnames\&. For example, a change that moves \fBarch/i386/Makefile\fR to \fBarch/x86/Makefile\fR while modifying 4 lines will be shown like this:
  2039. .sp
  2040. .if n \{\
  2041. .RS 4
  2042. .\}
  2043. .nf
  2044. arch/{i386 => x86}/Makefile | 4 +\-\-
  2045. .fi
  2046. .if n \{\
  2047. .RE
  2048. .\}
  2049. .sp
  2050. The \fB\-\-numstat\fR option gives the diffstat(1) information but is designed for easier machine consumption\&. An entry in \fB\-\-numstat\fR output looks like this:
  2051. .sp
  2052. .if n \{\
  2053. .RS 4
  2054. .\}
  2055. .nf
  2056. 1 2 README
  2057. 3 1 arch/{i386 => x86}/Makefile
  2058. .fi
  2059. .if n \{\
  2060. .RE
  2061. .\}
  2062. .sp
  2063. That is, from left to right:
  2064. .sp
  2065. .RS 4
  2066. .ie n \{\
  2067. \h'-04' 1.\h'+01'\c
  2068. .\}
  2069. .el \{\
  2070. .sp -1
  2071. .IP " 1." 4.2
  2072. .\}
  2073. the number of added lines;
  2074. .RE
  2075. .sp
  2076. .RS 4
  2077. .ie n \{\
  2078. \h'-04' 2.\h'+01'\c
  2079. .\}
  2080. .el \{\
  2081. .sp -1
  2082. .IP " 2." 4.2
  2083. .\}
  2084. a tab;
  2085. .RE
  2086. .sp
  2087. .RS 4
  2088. .ie n \{\
  2089. \h'-04' 3.\h'+01'\c
  2090. .\}
  2091. .el \{\
  2092. .sp -1
  2093. .IP " 3." 4.2
  2094. .\}
  2095. the number of deleted lines;
  2096. .RE
  2097. .sp
  2098. .RS 4
  2099. .ie n \{\
  2100. \h'-04' 4.\h'+01'\c
  2101. .\}
  2102. .el \{\
  2103. .sp -1
  2104. .IP " 4." 4.2
  2105. .\}
  2106. a tab;
  2107. .RE
  2108. .sp
  2109. .RS 4
  2110. .ie n \{\
  2111. \h'-04' 5.\h'+01'\c
  2112. .\}
  2113. .el \{\
  2114. .sp -1
  2115. .IP " 5." 4.2
  2116. .\}
  2117. pathname (possibly with rename/copy information);
  2118. .RE
  2119. .sp
  2120. .RS 4
  2121. .ie n \{\
  2122. \h'-04' 6.\h'+01'\c
  2123. .\}
  2124. .el \{\
  2125. .sp -1
  2126. .IP " 6." 4.2
  2127. .\}
  2128. a newline\&.
  2129. .RE
  2130. .sp
  2131. When \fB\-z\fR output option is in effect, the output is formatted this way:
  2132. .sp
  2133. .if n \{\
  2134. .RS 4
  2135. .\}
  2136. .nf
  2137. 1 2 README NUL
  2138. 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
  2139. .fi
  2140. .if n \{\
  2141. .RE
  2142. .\}
  2143. .sp
  2144. That is:
  2145. .sp
  2146. .RS 4
  2147. .ie n \{\
  2148. \h'-04' 1.\h'+01'\c
  2149. .\}
  2150. .el \{\
  2151. .sp -1
  2152. .IP " 1." 4.2
  2153. .\}
  2154. the number of added lines;
  2155. .RE
  2156. .sp
  2157. .RS 4
  2158. .ie n \{\
  2159. \h'-04' 2.\h'+01'\c
  2160. .\}
  2161. .el \{\
  2162. .sp -1
  2163. .IP " 2." 4.2
  2164. .\}
  2165. a tab;
  2166. .RE
  2167. .sp
  2168. .RS 4
  2169. .ie n \{\
  2170. \h'-04' 3.\h'+01'\c
  2171. .\}
  2172. .el \{\
  2173. .sp -1
  2174. .IP " 3." 4.2
  2175. .\}
  2176. the number of deleted lines;
  2177. .RE
  2178. .sp
  2179. .RS 4
  2180. .ie n \{\
  2181. \h'-04' 4.\h'+01'\c
  2182. .\}
  2183. .el \{\
  2184. .sp -1
  2185. .IP " 4." 4.2
  2186. .\}
  2187. a tab;
  2188. .RE
  2189. .sp
  2190. .RS 4
  2191. .ie n \{\
  2192. \h'-04' 5.\h'+01'\c
  2193. .\}
  2194. .el \{\
  2195. .sp -1
  2196. .IP " 5." 4.2
  2197. .\}
  2198. a NUL (only exists if renamed/copied);
  2199. .RE
  2200. .sp
  2201. .RS 4
  2202. .ie n \{\
  2203. \h'-04' 6.\h'+01'\c
  2204. .\}
  2205. .el \{\
  2206. .sp -1
  2207. .IP " 6." 4.2
  2208. .\}
  2209. pathname in preimage;
  2210. .RE
  2211. .sp
  2212. .RS 4
  2213. .ie n \{\
  2214. \h'-04' 7.\h'+01'\c
  2215. .\}
  2216. .el \{\
  2217. .sp -1
  2218. .IP " 7." 4.2
  2219. .\}
  2220. a NUL (only exists if renamed/copied);
  2221. .RE
  2222. .sp
  2223. .RS 4
  2224. .ie n \{\
  2225. \h'-04' 8.\h'+01'\c
  2226. .\}
  2227. .el \{\
  2228. .sp -1
  2229. .IP " 8." 4.2
  2230. .\}
  2231. pathname in postimage (only exists if renamed/copied);
  2232. .RE
  2233. .sp
  2234. .RS 4
  2235. .ie n \{\
  2236. \h'-04' 9.\h'+01'\c
  2237. .\}
  2238. .el \{\
  2239. .sp -1
  2240. .IP " 9." 4.2
  2241. .\}
  2242. a NUL\&.
  2243. .RE
  2244. .sp
  2245. The extra \fBNUL\fR before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single\-path record or a rename/copy record without reading ahead\&. After reading added and deleted lines, reading up to \fBNUL\fR would yield the pathname, but if that is \fBNUL\fR, the record will show two paths\&.
  2246. .SH "EXAMPLES"
  2247. .PP
  2248. Various ways to check your working tree
  2249. .RS 4
  2250. .sp
  2251. .if n \{\
  2252. .RS 4
  2253. .\}
  2254. .nf
  2255. $ git diff \fB(1)\fR
  2256. $ git diff \-\-cached \fB(2)\fR
  2257. $ git diff HEAD \fB(3)\fR
  2258. $ git diff AUTO_MERGE \fB(4)\fR
  2259. .fi
  2260. .if n \{\
  2261. .RE
  2262. .\}
  2263. .TS
  2264. tab(:);
  2265. r lw(\n(.lu*75u/100u).
  2266. \fB1.\fR\h'-2n':T{
  2267. Changes in the working tree not yet staged for the next commit\&.
  2268. T}
  2269. \fB2.\fR\h'-2n':T{
  2270. Changes between the index and your last commit; what you would be committing if you run
  2271. \fBgit\fR
  2272. \fBcommit\fR
  2273. without
  2274. \fB\-a\fR
  2275. option\&.
  2276. T}
  2277. \fB3.\fR\h'-2n':T{
  2278. Changes in the working tree since your last commit; what you would be committing if you run
  2279. \fBgit\fR
  2280. \fBcommit\fR
  2281. \fB\-a\fR
  2282. T}
  2283. \fB4.\fR\h'-2n':T{
  2284. Changes in the working tree you\(cqve made to resolve textual conflicts so far\&.
  2285. T}
  2286. .TE
  2287. .RE
  2288. .PP
  2289. Comparing with arbitrary commits
  2290. .RS 4
  2291. .sp
  2292. .if n \{\
  2293. .RS 4
  2294. .\}
  2295. .nf
  2296. $ git diff test \fB(1)\fR
  2297. $ git diff HEAD \-\- \&./test \fB(2)\fR
  2298. $ git diff HEAD^ HEAD \fB(3)\fR
  2299. .fi
  2300. .if n \{\
  2301. .RE
  2302. .\}
  2303. .TS
  2304. tab(:);
  2305. r lw(\n(.lu*75u/100u).
  2306. \fB1.\fR\h'-2n':T{
  2307. Instead of using the tip of the current branch, compare with the tip of "test" branch\&.
  2308. T}
  2309. \fB2.\fR\h'-2n':T{
  2310. 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"\&.
  2311. T}
  2312. \fB3.\fR\h'-2n':T{
  2313. Compare the version before the last commit and the last commit\&.
  2314. T}
  2315. .TE
  2316. .RE
  2317. .PP
  2318. Comparing branches
  2319. .RS 4
  2320. .sp
  2321. .if n \{\
  2322. .RS 4
  2323. .\}
  2324. .nf
  2325. $ git diff topic master \fB(1)\fR
  2326. $ git diff topic\&.\&.master \fB(2)\fR
  2327. $ git diff topic\&.\&.\&.master \fB(3)\fR
  2328. .fi
  2329. .if n \{\
  2330. .RE
  2331. .\}
  2332. .TS
  2333. tab(:);
  2334. r lw(\n(.lu*75u/100u).
  2335. \fB1.\fR\h'-2n':T{
  2336. Changes between the tips of the topic and the master branches\&.
  2337. T}
  2338. \fB2.\fR\h'-2n':T{
  2339. Same as above\&.
  2340. T}
  2341. \fB3.\fR\h'-2n':T{
  2342. Changes that occurred on the master branch since when the topic branch was started off it\&.
  2343. T}
  2344. .TE
  2345. .RE
  2346. .PP
  2347. Limiting the diff output
  2348. .RS 4
  2349. .sp
  2350. .if n \{\
  2351. .RS 4
  2352. .\}
  2353. .nf
  2354. $ git diff \-\-diff\-filter=MRC \fB(1)\fR
  2355. $ git diff \-\-name\-status \fB(2)\fR
  2356. $ git diff arch/i386 include/asm\-i386 \fB(3)\fR
  2357. .fi
  2358. .if n \{\
  2359. .RE
  2360. .\}
  2361. .TS
  2362. tab(:);
  2363. r lw(\n(.lu*75u/100u).
  2364. \fB1.\fR\h'-2n':T{
  2365. Show only modification, rename, and copy, but not addition or deletion\&.
  2366. T}
  2367. \fB2.\fR\h'-2n':T{
  2368. Show only names and the nature of change, but not actual diff output\&.
  2369. T}
  2370. \fB3.\fR\h'-2n':T{
  2371. Limit diff output to named subtrees\&.
  2372. T}
  2373. .TE
  2374. .RE
  2375. .PP
  2376. Munging the diff output
  2377. .RS 4
  2378. .sp
  2379. .if n \{\
  2380. .RS 4
  2381. .\}
  2382. .nf
  2383. $ git diff \-\-find\-copies\-harder \-B \-C \fB(1)\fR
  2384. $ git diff \-R \fB(2)\fR
  2385. .fi
  2386. .if n \{\
  2387. .RE
  2388. .\}
  2389. .TS
  2390. tab(:);
  2391. r lw(\n(.lu*75u/100u).
  2392. \fB1.\fR\h'-2n':T{
  2393. Spend extra cycles to find renames, copies and complete rewrites (very expensive)\&.
  2394. T}
  2395. \fB2.\fR\h'-2n':T{
  2396. Output diff in reverse\&.
  2397. T}
  2398. .TE
  2399. .RE
  2400. .SH "CONFIGURATION"
  2401. .sp
  2402. Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
  2403. .PP
  2404. \fBdiff\&.autoRefreshIndex\fR
  2405. .RS 4
  2406. When using
  2407. \fBgit\fR
  2408. \fBdiff\fR
  2409. to compare with work tree files, do not consider stat\-only changes as changed\&. Instead, silently run
  2410. \fBgit\fR
  2411. \fBupdate\-index\fR
  2412. \fB\-\-refresh\fR
  2413. to update the cached stat information for paths whose contents in the work tree match the contents in the index\&. This option defaults to
  2414. \fBtrue\fR\&. Note that this affects only
  2415. \fBgit\fR
  2416. \fBdiff\fR
  2417. Porcelain, and not lower level
  2418. \fBdiff\fR
  2419. commands such as
  2420. \fBgit\fR
  2421. \fBdiff\-files\fR\&.
  2422. .RE
  2423. .PP
  2424. \fBdiff\&.dirstat\fR
  2425. .RS 4
  2426. A comma separated list of
  2427. \fB\-\-dirstat\fR
  2428. parameters specifying the default behavior of the
  2429. \fB\-\-dirstat\fR
  2430. option to
  2431. \fBgit\fR
  2432. \fBdiff\fR
  2433. and friends\&. The defaults can be overridden on the command line (using
  2434. \fB\-\-dirstat=\fR\fI<param>\fR\fB,\&.\&.\fR\&.)\&. The fallback defaults (when not changed by
  2435. \fBdiff\&.dirstat\fR) are
  2436. \fBchanges,noncumulative,3\fR\&. The following parameters are available:
  2437. .PP
  2438. \fBchanges\fR
  2439. .RS 4
  2440. Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination\&. This ignores the amount of pure code movements within a file\&. In other words, rearranging lines in a file is not counted as much as other changes\&. This is the default behavior when no parameter is given\&.
  2441. .RE
  2442. .PP
  2443. \fBlines\fR
  2444. .RS 4
  2445. Compute the dirstat numbers by doing the regular line\-based diff analysis, and summing the removed/added line counts\&. (For binary files, count 64\-byte chunks instead, since binary files have no natural concept of lines)\&. This is a more expensive
  2446. \fB\-\-dirstat\fR
  2447. behavior than the
  2448. \fBchanges\fR
  2449. behavior, but it does count rearranged lines within a file as much as other changes\&. The resulting output is consistent with what you get from the other
  2450. \fB\-\-\fR*stat options\&.
  2451. .RE
  2452. .PP
  2453. \fBfiles\fR
  2454. .RS 4
  2455. Compute the dirstat numbers by counting the number of files changed\&. Each changed file counts equally in the dirstat analysis\&. This is the computationally cheapest
  2456. \fB\-\-dirstat\fR
  2457. behavior, since it does not have to look at the file contents at all\&.
  2458. .RE
  2459. .PP
  2460. \fBcumulative\fR
  2461. .RS 4
  2462. Count changes in a child directory for the parent directory as well\&. Note that when using
  2463. \fBcumulative\fR, the sum of the percentages reported may exceed 100%\&. The default (non\-cumulative) behavior can be specified with the
  2464. \fBnoncumulative\fR
  2465. parameter\&.
  2466. .RE
  2467. .PP
  2468. \fI<limit>\fR
  2469. .RS 4
  2470. An integer parameter specifies a cut\-off percent (3% by default)\&. Directories contributing less than this percentage of the changes are not shown in the output\&.
  2471. .RE
  2472. .sp
  2473. Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories:
  2474. \fBfiles,10,cumulative\fR\&.
  2475. .RE
  2476. .PP
  2477. \fBdiff\&.statNameWidth\fR
  2478. .RS 4
  2479. Limit the width of the filename part in
  2480. \fB\-\-stat\fR
  2481. output\&. If set, applies to all commands generating
  2482. \fB\-\-stat\fR
  2483. output except
  2484. \fBformat\-patch\fR\&.
  2485. .RE
  2486. .PP
  2487. \fBdiff\&.statGraphWidth\fR
  2488. .RS 4
  2489. Limit the width of the graph part in
  2490. \fB\-\-stat\fR
  2491. output\&. If set, applies to all commands generating
  2492. \fB\-\-stat\fR
  2493. output except
  2494. \fBformat\-patch\fR\&.
  2495. .RE
  2496. .PP
  2497. \fBdiff\&.context\fR
  2498. .RS 4
  2499. Generate diffs with
  2500. \fI<n>\fR
  2501. lines of context instead of the default of 3\&. This value is overridden by the
  2502. \fB\-U\fR
  2503. option\&.
  2504. .RE
  2505. .PP
  2506. \fBdiff\&.interHunkContext\fR
  2507. .RS 4
  2508. Show the context between diff hunks, up to the specified number of lines, thereby fusing the hunks that are close to each other\&. This value serves as the default for the
  2509. \fB\-\-inter\-hunk\-context\fR
  2510. command line option\&.
  2511. .RE
  2512. .PP
  2513. \fBdiff\&.external\fR
  2514. .RS 4
  2515. If this config variable is set, diff generation is not performed using the internal diff machinery, but using the given command\&. Can be overridden with the
  2516. \fBGIT_EXTERNAL_DIFF\fR
  2517. environment variable\&. The command is called with parameters as described under "git Diffs" in
  2518. \fBgit\fR(1)\&. Note: if you want to use an external diff program only on a subset of your files, you might want to use
  2519. \fBgitattributes\fR(5)
  2520. instead\&.
  2521. .RE
  2522. .PP
  2523. \fBdiff\&.trustExitCode\fR
  2524. .RS 4
  2525. If this boolean value is set to
  2526. \fBtrue\fR
  2527. then the
  2528. \fBdiff\&.external\fR
  2529. command is expected to return exit code 0 if it considers the input files to be equal or 1 if it considers them to be different, like
  2530. \fBdiff\fR(1)\&. If it is set to
  2531. \fBfalse\fR, which is the default, then the command is expected to return exit code
  2532. \fB0\fR
  2533. regardless of equality\&. Any other exit code causes Git to report a fatal error\&.
  2534. .RE
  2535. .PP
  2536. \fBdiff\&.ignoreSubmodules\fR
  2537. .RS 4
  2538. Sets the default value of
  2539. \fB\-\-ignore\-submodules\fR\&. Note that this affects only
  2540. \fBgit\fR
  2541. \fBdiff\fR
  2542. Porcelain, and not lower level
  2543. \fBdiff\fR
  2544. commands such as
  2545. \fBgit\fR
  2546. \fBdiff\-files\fR\&.
  2547. \fBgit\fR
  2548. \fBcheckout\fR
  2549. and
  2550. \fBgit\fR
  2551. \fBswitch\fR
  2552. also honor this setting when reporting uncommitted changes\&. Setting it to
  2553. \fBall\fR
  2554. disables the submodule summary normally shown by
  2555. \fBgit\fR
  2556. \fBcommit\fR
  2557. and
  2558. \fBgit\fR
  2559. \fBstatus\fR
  2560. when
  2561. \fBstatus\&.submoduleSummary\fR
  2562. is set unless it is overridden by using the
  2563. \fB\-\-ignore\-submodules\fR
  2564. command\-line option\&. The
  2565. \fBgit\fR
  2566. \fBsubmodule\fR
  2567. commands are not affected by this setting\&. By default this is set to untracked so that any untracked submodules are ignored\&.
  2568. .RE
  2569. .PP
  2570. \fBdiff\&.mnemonicPrefix\fR
  2571. .RS 4
  2572. If set,
  2573. \fBgit\fR
  2574. \fBdiff\fR
  2575. uses a prefix pair that is different from the standard
  2576. \fBa/\fR
  2577. and
  2578. \fBb/\fR
  2579. depending on what is being compared\&. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:
  2580. .PP
  2581. \fBgit\fR \fBdiff\fR
  2582. .RS 4
  2583. compares the (i)ndex and the (w)ork tree;
  2584. .RE
  2585. .PP
  2586. \fBgit\fR \fBdiff\fR \fBHEAD\fR
  2587. .RS 4
  2588. compares a (c)ommit and the (w)ork tree;
  2589. .RE
  2590. .PP
  2591. \fBgit\fR \fBdiff\fR \fB\-\-cached\fR
  2592. .RS 4
  2593. compares a (c)ommit and the (i)ndex;
  2594. .RE
  2595. .PP
  2596. \fBgit\fR \fBdiff\fR \fBHEAD:\fR\fI<file1>\fR \fI<file2>\fR
  2597. .RS 4
  2598. compares an (o)bject and a (w)ork tree entity;
  2599. .RE
  2600. .PP
  2601. \fBgit\fR \fBdiff\fR \fB\-\-no\-index\fR \fI<a>\fR \fI<b>\fR
  2602. .RS 4
  2603. compares two non\-git things
  2604. \fI<a>\fR
  2605. and
  2606. \fI<b>\fR\&.
  2607. .RE
  2608. .RE
  2609. .PP
  2610. \fBdiff\&.noPrefix\fR
  2611. .RS 4
  2612. If set,
  2613. \fBgit\fR
  2614. \fBdiff\fR
  2615. does not show any source or destination prefix\&.
  2616. .RE
  2617. .PP
  2618. \fBdiff\&.srcPrefix\fR
  2619. .RS 4
  2620. If set,
  2621. \fBgit\fR
  2622. \fBdiff\fR
  2623. uses this source prefix\&. Defaults to
  2624. \fBa/\fR\&.
  2625. .RE
  2626. .PP
  2627. \fBdiff\&.dstPrefix\fR
  2628. .RS 4
  2629. If set,
  2630. \fBgit\fR
  2631. \fBdiff\fR
  2632. uses this destination prefix\&. Defaults to
  2633. \fBb/\fR\&.
  2634. .RE
  2635. .PP
  2636. \fBdiff\&.relative\fR
  2637. .RS 4
  2638. If set to
  2639. \fBtrue\fR,
  2640. \fBgit\fR
  2641. \fBdiff\fR
  2642. does not show changes outside of the directory and show pathnames relative to the current directory\&.
  2643. .RE
  2644. .PP
  2645. \fBdiff\&.orderFile\fR
  2646. .RS 4
  2647. File indicating how to order files within a diff\&. See the
  2648. \fB\-O\fR
  2649. option for details\&. If
  2650. \fBdiff\&.orderFile\fR
  2651. is a relative pathname, it is treated as relative to the top of the working tree\&.
  2652. .RE
  2653. .PP
  2654. \fBdiff\&.renameLimit\fR
  2655. .RS 4
  2656. The number of files to consider in the exhaustive portion of copy/rename detection; equivalent to the
  2657. \fBgit\fR
  2658. \fBdiff\fR
  2659. option
  2660. \fB\-l\fR\&. If not set, the default value is currently 1000\&. This setting has no effect if rename detection is turned off\&.
  2661. .RE
  2662. .PP
  2663. \fBdiff\&.renames\fR
  2664. .RS 4
  2665. Whether and how Git detects renames\&. If set to
  2666. \fBfalse\fR, rename detection is disabled\&. If set to
  2667. \fBtrue\fR, basic rename detection is enabled\&. If set to
  2668. \fBcopies\fR
  2669. or
  2670. \fBcopy\fR, Git will detect copies, as well\&. Defaults to
  2671. \fBtrue\fR\&. Note that this affects only
  2672. \fBgit\fR
  2673. \fBdiff\fR
  2674. Porcelain like
  2675. \fBgit-diff\fR(1)
  2676. and
  2677. \fBgit-log\fR(1), and not lower level commands such as
  2678. \fBgit-diff-files\fR(1)\&.
  2679. .RE
  2680. .PP
  2681. \fBdiff\&.suppressBlankEmpty\fR
  2682. .RS 4
  2683. A boolean to inhibit the standard behavior of printing a space before each empty output line\&. Defaults to
  2684. \fBfalse\fR\&.
  2685. .RE
  2686. .PP
  2687. \fBdiff\&.submodule\fR
  2688. .RS 4
  2689. Specify the format in which differences in submodules are shown\&. The
  2690. \fBshort\fR
  2691. format just shows the names of the commits at the beginning and end of the range\&. The
  2692. \fBlog\fR
  2693. format lists the commits in the range like
  2694. \fBgit-submodule\fR(1)
  2695. \fBsummary\fR
  2696. does\&. The
  2697. \fBdiff\fR
  2698. format shows an inline diff of the changed contents of the submodule\&. Defaults to
  2699. \fBshort\fR\&.
  2700. .RE
  2701. .PP
  2702. \fBdiff\&.wordRegex\fR
  2703. .RS 4
  2704. A POSIX Extended Regular Expression used to determine what is a "word" when performing word\-by\-word difference calculations\&. Character sequences that match the regular expression are "words", all other characters are
  2705. \fBignorable\fR
  2706. whitespace\&.
  2707. .RE
  2708. .PP
  2709. \fBdiff\&.\fR\fI<driver>\fR\fB\&.command\fR
  2710. .RS 4
  2711. The custom diff driver command\&. See
  2712. \fBgitattributes\fR(5)
  2713. for details\&.
  2714. .RE
  2715. .PP
  2716. \fBdiff\&.\fR\fI<driver>\fR\fB\&.trustExitCode\fR
  2717. .RS 4
  2718. If this boolean value is set to
  2719. \fBtrue\fR
  2720. then the
  2721. \fBdiff\&.\fR\fI<driver>\fR\fB\&.command\fR
  2722. command is expected to return exit code 0 if it considers the input files to be equal or 1 if it considers them to be different, like
  2723. \fBdiff\fR(1)\&. If it is set to
  2724. \fBfalse\fR, which is the default, then the command is expected to return exit code 0 regardless of equality\&. Any other exit code causes Git to report a fatal error\&.
  2725. .RE
  2726. .PP
  2727. \fBdiff\&.\fR\fI<driver>\fR\fB\&.xfuncname\fR
  2728. .RS 4
  2729. The regular expression that the diff driver should use to recognize the hunk header\&. A built\-in pattern may also be used\&. See
  2730. \fBgitattributes\fR(5)
  2731. for details\&.
  2732. .RE
  2733. .PP
  2734. \fBdiff\&.\fR\fI<driver>\fR\fB\&.binary\fR
  2735. .RS 4
  2736. Set this option to
  2737. \fBtrue\fR
  2738. to make the diff driver treat files as binary\&. See
  2739. \fBgitattributes\fR(5)
  2740. for details\&.
  2741. .RE
  2742. .PP
  2743. \fBdiff\&.\fR\fI<driver>\fR\fB\&.textconv\fR
  2744. .RS 4
  2745. The command that the diff driver should call to generate the text\-converted version of a file\&. The result of the conversion is used to generate a human\-readable diff\&. See
  2746. \fBgitattributes\fR(5)
  2747. for details\&.
  2748. .RE
  2749. .PP
  2750. \fBdiff\&.\fR\fI<driver>\fR\fB\&.wordRegex\fR
  2751. .RS 4
  2752. The regular expression that the diff driver should use to split words in a line\&. See
  2753. \fBgitattributes\fR(5)
  2754. for details\&.
  2755. .RE
  2756. .PP
  2757. \fBdiff\&.\fR\fI<driver>\fR\fB\&.cachetextconv\fR
  2758. .RS 4
  2759. Set this option to
  2760. \fBtrue\fR
  2761. to make the diff driver cache the text conversion outputs\&. See
  2762. \fBgitattributes\fR(5)
  2763. for details\&.
  2764. .RE
  2765. .PP
  2766. \fBdiff\&.indentHeuristic\fR
  2767. .RS 4
  2768. Set this option to
  2769. \fBfalse\fR
  2770. to disable the default heuristics that shift diff hunk boundaries to make patches easier to read\&.
  2771. .RE
  2772. .PP
  2773. \fBdiff\&.algorithm\fR
  2774. .RS 4
  2775. Choose a diff algorithm\&. The variants are as follows:
  2776. .PP
  2777. \fBdefault\fR, \fBmyers\fR
  2778. .RS 4
  2779. The basic greedy diff algorithm\&. Currently, this is the default\&.
  2780. .RE
  2781. .PP
  2782. \fBminimal\fR
  2783. .RS 4
  2784. Spend extra time to make sure the smallest possible diff is produced\&.
  2785. .RE
  2786. .PP
  2787. \fBpatience\fR
  2788. .RS 4
  2789. Use "patience diff" algorithm when generating patches\&.
  2790. .RE
  2791. .PP
  2792. \fBhistogram\fR
  2793. .RS 4
  2794. This algorithm extends the patience algorithm to "support low\-occurrence common elements"\&.
  2795. .RE
  2796. .RE
  2797. .PP
  2798. \fBdiff\&.wsErrorHighlight\fR
  2799. .RS 4
  2800. Highlight whitespace errors in the
  2801. \fBcontext\fR,
  2802. \fBold\fR
  2803. or
  2804. \fBnew\fR
  2805. lines of the diff\&. Multiple values are separated by comma,
  2806. \fBnone\fR
  2807. resets previous values,
  2808. \fBdefault\fR
  2809. reset the list to
  2810. \fBnew\fR
  2811. and
  2812. \fBall\fR
  2813. is a shorthand for
  2814. \fBold,new,context\fR\&. The whitespace errors are colored with
  2815. \fBcolor\&.diff\&.whitespace\fR\&. The command line option
  2816. \fB\-\-ws\-error\-highlight=\fR\fI<kind>\fR
  2817. overrides this setting\&.
  2818. .RE
  2819. .PP
  2820. \fBdiff\&.colorMoved\fR
  2821. .RS 4
  2822. If set to either a valid
  2823. \fI<mode>\fR
  2824. or a
  2825. \fBtrue\fR
  2826. value, moved lines in a diff are colored differently\&. For details of valid modes see
  2827. \fB\-\-color\-moved\fR\&. If simply set to
  2828. \fBtrue\fR
  2829. the default color mode will be used\&. When set to
  2830. \fBfalse\fR, moved lines are not colored\&.
  2831. .RE
  2832. .PP
  2833. \fBdiff\&.colorMovedWS\fR
  2834. .RS 4
  2835. When moved lines are colored using e\&.g\&. the
  2836. \fBdiff\&.colorMoved\fR
  2837. setting, this option controls the mode how spaces are treated\&. For details of valid modes see
  2838. \fB\-\-color\-moved\-ws\fR
  2839. in
  2840. \fBgit-diff\fR(1)\&.
  2841. .RE
  2842. .SH "SEE ALSO"
  2843. .sp
  2844. \fBdiff\fR(1), \fBgit-difftool\fR(1), \fBgit-log\fR(1), \fBgitdiffcore\fR(7), \fBgit-format-patch\fR(1), \fBgit-apply\fR(1), \fBgit-show\fR(1)
  2845. .SH "GIT"
  2846. .sp
  2847. Part of the \fBgit\fR(1) suite