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-commit.1 (33942B)


  1. '\" t
  2. .\" Title: git-commit
  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\-COMMIT" "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-commit \- Record changes to the repository
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fBgit\fR \fBcommit\fR [\fB\-a\fR | \fB\-\-interactive\fR | \fB\-\-patch\fR] [\fB\-s\fR] [\fB\-v\fR] [\fB\-u\fR[\fI<mode>\fR]] [\fB\-\-amend\fR]
  36. [\fB\-\-dry\-run\fR] [(\fB\-c\fR | \fB\-C\fR | \fB\-\-squash\fR) \fI<commit>\fR | \fB\-\-fixup\fR [(\fBamend\fR|\fBreword\fR)\fB:\fR]\fI<commit>\fR]
  37. [\fB\-F\fR \fI<file>\fR | \fB\-m\fR \fI<msg>\fR] [\fB\-\-reset\-author\fR] [\fB\-\-allow\-empty\fR]
  38. [\fB\-\-allow\-empty\-message\fR] [\fB\-\-no\-verify\fR] [\fB\-e\fR] [\fB\-\-author=\fR\fI<author>\fR]
  39. [\fB\-\-date=\fR\fI<date>\fR] [\fB\-\-cleanup=\fR\fI<mode>\fR] [\fB\-\-\fR[\fBno\-\fR]\fBstatus\fR]
  40. [\fB\-i\fR | \fB\-o\fR] [\fB\-\-pathspec\-from\-file=\fR\fI<file>\fR [\fB\-\-pathspec\-file\-nul\fR]]
  41. [(\fB\-\-trailer\fR \fI<token>\fR[(\fB=\fR|\fB:\fR)\fI<value>\fR])\&...\:] [\fB\-S\fR[\fI<keyid>\fR]]
  42. [\fB\-\-\fR] [\fI<pathspec>\fR\&...\:]
  43. .fi
  44. .SH "DESCRIPTION"
  45. .sp
  46. Create a new commit containing the current contents of the index and the given log message describing the changes\&. The new commit is a direct child of HEAD, usually the tip of the current branch, and the branch is updated to point to it (unless no branch is associated with the working tree, in which case \fBHEAD\fR is "detached" as described in \fBgit-checkout\fR(1))\&.
  47. .sp
  48. The content to be committed can be specified in several ways:
  49. .sp
  50. .RS 4
  51. .ie n \{\
  52. \h'-04' 1.\h'+01'\c
  53. .\}
  54. .el \{\
  55. .sp -1
  56. .IP " 1." 4.2
  57. .\}
  58. by using
  59. \fBgit-add\fR(1)
  60. to incrementally "add" changes to the index before using the
  61. \fBcommit\fR
  62. command (Note: even modified files must be "added");
  63. .RE
  64. .sp
  65. .RS 4
  66. .ie n \{\
  67. \h'-04' 2.\h'+01'\c
  68. .\}
  69. .el \{\
  70. .sp -1
  71. .IP " 2." 4.2
  72. .\}
  73. by using
  74. \fBgit-rm\fR(1)
  75. to remove files from the working tree and the index, again before using the
  76. \fBcommit\fR
  77. command;
  78. .RE
  79. .sp
  80. .RS 4
  81. .ie n \{\
  82. \h'-04' 3.\h'+01'\c
  83. .\}
  84. .el \{\
  85. .sp -1
  86. .IP " 3." 4.2
  87. .\}
  88. by listing files as arguments to the
  89. \fBcommit\fR
  90. command (without
  91. \fB\-\-interactive\fR
  92. or
  93. \fB\-\-patch\fR
  94. switch), in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already be known to Git);
  95. .RE
  96. .sp
  97. .RS 4
  98. .ie n \{\
  99. \h'-04' 4.\h'+01'\c
  100. .\}
  101. .el \{\
  102. .sp -1
  103. .IP " 4." 4.2
  104. .\}
  105. by using the
  106. \fB\-a\fR
  107. switch with the
  108. \fBcommit\fR
  109. command to automatically "add" changes from all known files (i\&.e\&. all files that are already listed in the index) and to automatically "rm" files in the index that have been removed from the working tree, and then perform the actual commit;
  110. .RE
  111. .sp
  112. .RS 4
  113. .ie n \{\
  114. \h'-04' 5.\h'+01'\c
  115. .\}
  116. .el \{\
  117. .sp -1
  118. .IP " 5." 4.2
  119. .\}
  120. by using the
  121. \fB\-\-interactive\fR
  122. or
  123. \fB\-\-patch\fR
  124. switches with the
  125. \fBcommit\fR
  126. command to decide one by one which files or hunks should be part of the commit in addition to contents in the index, before finalizing the operation\&. See the
  127. \(lqInteractive Mode\(rq
  128. section of
  129. \fBgit-add\fR(1)
  130. to learn how to operate these modes\&.
  131. .RE
  132. .sp
  133. The \fB\-\-dry\-run\fR option can be used to obtain a summary of what is included by any of the above for the next commit by giving the same set of parameters (options and paths)\&.
  134. .sp
  135. If you make a commit and then find a mistake immediately after that, you can recover from it with \fBgit\fR \fBreset\fR\&.
  136. .SH "OPTIONS"
  137. .PP
  138. \fB\-a\fR, \fB\-\-all\fR
  139. .RS 4
  140. Automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected\&.
  141. .RE
  142. .PP
  143. \fB\-p\fR, \fB\-\-patch\fR
  144. .RS 4
  145. Use the interactive patch selection interface to choose which changes to commit\&. See
  146. \fBgit-add\fR(1)
  147. for details\&.
  148. .RE
  149. .PP
  150. \fB\-C\fR \fI<commit>\fR, \fB\-\-reuse\-message=\fR\fI<commit>\fR
  151. .RS 4
  152. Take an existing
  153. \fI<commit>\fR
  154. object, and reuse the log message and the authorship information (including the timestamp) when creating the commit\&.
  155. .RE
  156. .PP
  157. \fB\-c\fR \fI<commit>\fR, \fB\-\-reedit\-message=\fR\fI<commit>\fR
  158. .RS 4
  159. Like
  160. \fB\-C\fR, but with
  161. \fB\-c\fR
  162. the editor is invoked, so that the user can further edit the commit message\&.
  163. .RE
  164. .PP
  165. \fB\-\-fixup=\fR[(\fBamend\fR|\fBreword\fR)\fB:\fR]\fI<commit>\fR
  166. .RS 4
  167. Create a new commit which "fixes up"
  168. \fI<commit>\fR
  169. when applied with
  170. \fBgit\fR
  171. \fBrebase\fR
  172. \fB\-\-autosquash\fR\&. Plain
  173. \fB\-\-fixup=\fR\fI<commit>\fR
  174. creates a "fixup!" commit which changes the content of
  175. \fI<commit>\fR
  176. but leaves its log message untouched\&.
  177. \fB\-\-fixup=amend:\fR\fI<commit>\fR
  178. is similar but creates an "amend!" commit which also replaces the log message of
  179. \fI<commit>\fR
  180. with the log message of the "amend!" commit\&.
  181. \fB\-\-fixup=reword:\fR\fI<commit>\fR
  182. creates an "amend!" commit which replaces the log message of
  183. \fI<commit>\fR
  184. with its own log message but makes no changes to the content of
  185. \fI<commit>\fR\&.
  186. .sp
  187. The commit created by plain
  188. \fB\-\-fixup=\fR\fI<commit>\fR
  189. has a title composed of "fixup!" followed by the title of
  190. \fI<commit>\fR, and is recognized specially by
  191. \fBgit\fR
  192. \fBrebase\fR
  193. \fB\-\-autosquash\fR\&. The
  194. \fB\-m\fR
  195. option may be used to supplement the log message of the created commit, but the additional commentary will be thrown away once the "fixup!" commit is squashed into
  196. \fI<commit>\fR
  197. by
  198. \fBgit\fR
  199. \fBrebase\fR
  200. \fB\-\-autosquash\fR\&.
  201. .sp
  202. The commit created by
  203. \fB\-\-fixup=amend:\fR\fI<commit>\fR
  204. is similar but its title is instead prefixed with "amend!"\&. The log message of
  205. \fI<commit>\fR
  206. is copied into the log message of the "amend!" commit and opened in an editor so it can be refined\&. When
  207. \fBgit\fR
  208. \fBrebase\fR
  209. \fB\-\-autosquash\fR
  210. squashes the "amend!" commit into
  211. \fI<commit>\fR, the log message of
  212. \fI<commit>\fR
  213. is replaced by the refined log message from the "amend!" commit\&. It is an error for the "amend!" commit\(cqs log message to be empty unless
  214. \fB\-\-allow\-empty\-message\fR
  215. is specified\&.
  216. .sp
  217. \fB\-\-fixup=reword:\fR\fI<commit>\fR
  218. is shorthand for
  219. \fB\-\-fixup=amend:\fR\fI<commit>\fR
  220. \fB\-\-only\fR\&. It creates an "amend!" commit with only a log message (ignoring any changes staged in the index)\&. When squashed by
  221. \fBgit\fR
  222. \fBrebase\fR
  223. \fB\-\-autosquash\fR, it replaces the log message of
  224. \fI<commit>\fR
  225. without making any other changes\&.
  226. .sp
  227. Neither "fixup!" nor "amend!" commits change authorship of
  228. \fI<commit>\fR
  229. when applied by
  230. \fBgit\fR
  231. \fBrebase\fR
  232. \fB\-\-autosquash\fR\&. See
  233. \fBgit-rebase\fR(1)
  234. for details\&.
  235. .RE
  236. .PP
  237. \fB\-\-squash=\fR\fI<commit>\fR
  238. .RS 4
  239. Construct a commit message for use with
  240. \fBgit\fR
  241. \fBrebase\fR
  242. \fB\-\-autosquash\fR\&. The commit message title is taken from the specified commit with a prefix of "squash! "\&. Can be used with additional commit message options (\fB\-m\fR/\fB\-c\fR/\fB\-C\fR/\fB\-F\fR)\&. See
  243. \fBgit-rebase\fR(1)
  244. for details\&.
  245. .RE
  246. .PP
  247. \fB\-\-reset\-author\fR
  248. .RS 4
  249. When used with
  250. \fB\-C\fR/\fB\-c\fR/\fB\-\-amend\fR
  251. options, or when committing after a conflicting cherry\-pick, declare that the authorship of the resulting commit now belongs to the committer\&. This also renews the author timestamp\&.
  252. .RE
  253. .PP
  254. \fB\-\-short\fR
  255. .RS 4
  256. When doing a dry\-run, give the output in the short\-format\&. See
  257. \fBgit-status\fR(1)
  258. for details\&. Implies
  259. \fB\-\-dry\-run\fR\&.
  260. .RE
  261. .PP
  262. \fB\-\-branch\fR
  263. .RS 4
  264. Show the branch and tracking info even in short\-format\&.
  265. .RE
  266. .PP
  267. \fB\-\-porcelain\fR
  268. .RS 4
  269. When doing a dry\-run, give the output in a porcelain\-ready format\&. See
  270. \fBgit-status\fR(1)
  271. for details\&. Implies
  272. \fB\-\-dry\-run\fR\&.
  273. .RE
  274. .PP
  275. \fB\-\-long\fR
  276. .RS 4
  277. When doing a dry\-run, give the output in the long\-format\&. Implies
  278. \fB\-\-dry\-run\fR\&.
  279. .RE
  280. .PP
  281. \fB\-z\fR, \fB\-\-null\fR
  282. .RS 4
  283. When showing
  284. \fBshort\fR
  285. or
  286. \fBporcelain\fR
  287. status output, print the filename verbatim and terminate the entries with
  288. \fINUL\fR, instead of
  289. \fILF\fR\&. If no format is given, implies the
  290. \fB\-\-porcelain\fR
  291. output format\&. Without the
  292. \fB\-z\fR
  293. option, filenames with "unusual" characters are quoted as explained for the configuration variable
  294. \fBcore\&.quotePath\fR
  295. (see
  296. \fBgit-config\fR(1))\&.
  297. .RE
  298. .PP
  299. \fB\-F\fR \fI<file>\fR, \fB\-\-file=\fR\fI<file>\fR
  300. .RS 4
  301. Take the commit message from
  302. \fI<file>\fR\&. Use
  303. \fI\-\fR
  304. to read the message from the standard input\&.
  305. .RE
  306. .PP
  307. \fB\-\-author=\fR\fI<author>\fR
  308. .RS 4
  309. Override the commit author\&. Specify an explicit author using the standard
  310. \fBA\fR
  311. \fBU\fR
  312. \fBThor\fR
  313. <author@example\&.\fBcom\fR> format\&. Otherwise
  314. \fI<author>\fR
  315. is assumed to be a pattern and is used to search for an existing commit by that author (i\&.e\&.
  316. \fBgit\fR
  317. \fBrev\-list\fR
  318. \fB\-\-all\fR
  319. \fB\-i\fR
  320. \fB\-\-author=\fR\fI<author>\fR); the commit author is then copied from the first such commit found\&.
  321. .RE
  322. .PP
  323. \fB\-\-date=\fR\fI<date>\fR
  324. .RS 4
  325. Override the author date used in the commit\&.
  326. .RE
  327. .PP
  328. \fB\-m\fR \fI<msg>\fR, \fB\-\-message=\fR\fI<msg>\fR
  329. .RS 4
  330. Use
  331. \fI<msg>\fR
  332. as the commit message\&. If multiple
  333. \fB\-m\fR
  334. options are given, their values are concatenated as separate paragraphs\&.
  335. .sp
  336. The
  337. \fB\-m\fR
  338. option is mutually exclusive with
  339. \fB\-c\fR,
  340. \fB\-C\fR, and
  341. \fB\-F\fR\&.
  342. .RE
  343. .PP
  344. \fB\-t\fR \fI<file>\fR, \fB\-\-template=\fR\fI<file>\fR
  345. .RS 4
  346. When editing the commit message, start the editor with the contents in
  347. \fI<file>\fR\&. The
  348. \fBcommit\&.template\fR
  349. configuration variable is often used to give this option implicitly to the command\&. This mechanism can be used by projects that want to guide participants with some hints on what to write in the message in what order\&. If the user exits the editor without editing the message, the commit is aborted\&. This has no effect when a message is given by other means, e\&.g\&. with the
  350. \fB\-m\fR
  351. or
  352. \fB\-F\fR
  353. options\&.
  354. .RE
  355. .PP
  356. \fB\-s\fR, \fB\-\-signoff\fR, \fB\-\-no\-signoff\fR
  357. .RS 4
  358. Add a
  359. \fBSigned\-off\-by\fR
  360. trailer by the committer at the end of the commit log message\&. The meaning of a signoff depends on the project to which you\(cqre committing\&. For example, it may certify that the committer has the rights to submit the work under the project\(cqs license or agrees to some contributor representation, such as a Developer Certificate of Origin\&. (See
  361. \m[blue]\fBhttps://developercertificate\&.org\fR\m[]
  362. for the one used by the Linux kernel and Git projects\&.) Consult the documentation or leadership of the project to which you\(cqre contributing to understand how the signoffs are used in that project\&.
  363. .sp
  364. The
  365. \fB\-\-no\-signoff\fR
  366. option can be used to countermand an earlier
  367. \fB\-\-signoff\fR
  368. option on the command line\&.
  369. .RE
  370. .PP
  371. \fB\-\-trailer\fR \fI<token>\fR[(\fB=\fR|\fB:\fR)\fI<value>\fR]
  372. .RS 4
  373. Specify a (\fI<token>\fR,
  374. \fI<value>\fR) pair that should be applied as a trailer\&. (e\&.g\&.
  375. \fBgit\fR
  376. \fBcommit\fR
  377. \fB\-\-trailer\fR
  378. "Signed\-off\-by:C
  379. \fBO\fR
  380. \fBMitter\fR
  381. \e <committer@example\&.\fBcom\fR>"
  382. \fB\-\-trailer\fR
  383. "Helped\-by:C
  384. \fBO\fR
  385. \fBMitter\fR
  386. \e <committer@example\&.\fBcom\fR>" will add the
  387. \fBSigned\-off\-by\fR
  388. trailer and the
  389. \fBHelped\-by\fR
  390. trailer to the commit message\&.) The
  391. \fBtrailer\&.\fR* configuration variables (\fBgit-interpret-trailers\fR(1)) can be used to define if a duplicated trailer is omitted, where in the run of trailers each trailer would appear, and other details\&.
  392. .RE
  393. .PP
  394. \fB\-n\fR, \fB\-\-\fR[\fBno\-\fR]\fBverify\fR
  395. .RS 4
  396. Bypass the
  397. \fBpre\-commit\fR
  398. and
  399. \fBcommit\-msg\fR
  400. hooks\&. See also
  401. \fBgithooks\fR(5)\&.
  402. .RE
  403. .PP
  404. \fB\-\-allow\-empty\fR
  405. .RS 4
  406. Usually recording a commit that has the exact same tree as its sole parent commit is a mistake, and the command prevents you from making such a commit\&. This option bypasses the safety, and is primarily for use by foreign SCM interface scripts\&.
  407. .RE
  408. .PP
  409. \fB\-\-allow\-empty\-message\fR
  410. .RS 4
  411. Create a commit with an empty commit message without using plumbing commands like
  412. \fBgit-commit-tree\fR(1)\&. Like
  413. \fB\-\-allow\-empty\fR, this command is primarily for use by foreign SCM interface scripts\&.
  414. .RE
  415. .PP
  416. \fB\-\-cleanup=\fR\fI<mode>\fR
  417. .RS 4
  418. Determine how the supplied commit message should be cleaned up before committing\&. The
  419. \fI<mode>\fR
  420. can be
  421. \fBstrip\fR,
  422. \fBwhitespace\fR,
  423. \fBverbatim\fR,
  424. \fBscissors\fR
  425. or
  426. \fBdefault\fR\&.
  427. .PP
  428. \fBstrip\fR
  429. .RS 4
  430. Strip leading and trailing empty lines, trailing whitespace, commentary and collapse consecutive empty lines\&.
  431. .RE
  432. .PP
  433. \fBwhitespace\fR
  434. .RS 4
  435. Same as
  436. \fBstrip\fR
  437. except #commentary is not removed\&.
  438. .RE
  439. .PP
  440. \fBverbatim\fR
  441. .RS 4
  442. Do not change the message at all\&.
  443. .RE
  444. .PP
  445. \fBscissors\fR
  446. .RS 4
  447. Same as
  448. \fBwhitespace\fR
  449. except that everything from (and including) the line found below is truncated, if the message is to be edited\&. "#" can be customized with
  450. \fBcore\&.commentChar\fR\&.
  451. .sp
  452. .if n \{\
  453. .RS 4
  454. .\}
  455. .nf
  456. # \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- >8 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
  457. .fi
  458. .if n \{\
  459. .RE
  460. .\}
  461. .RE
  462. .PP
  463. \fBdefault\fR
  464. .RS 4
  465. Same as
  466. \fBstrip\fR
  467. if the message is to be edited\&. Otherwise
  468. \fBwhitespace\fR\&.
  469. .RE
  470. .sp
  471. The default can be changed by the
  472. \fBcommit\&.cleanup\fR
  473. configuration variable (see
  474. \fBgit-config\fR(1))\&.
  475. .RE
  476. .PP
  477. \fB\-e\fR, \fB\-\-edit\fR
  478. .RS 4
  479. Let the user further edit the message taken from
  480. \fI<file>\fR
  481. with
  482. \fB\-F\fR
  483. \fI<file>\fR, command line with
  484. \fB\-m\fR
  485. \fI<message>\fR, and from
  486. \fI<commit>\fR
  487. with
  488. \fB\-C\fR
  489. \fI<commit>\fR\&.
  490. .RE
  491. .PP
  492. \fB\-\-no\-edit\fR
  493. .RS 4
  494. Use the selected commit message without launching an editor\&. For example,
  495. \fBgit\fR
  496. \fBcommit\fR
  497. \fB\-\-amend\fR
  498. \fB\-\-no\-edit\fR
  499. amends a commit without changing its commit message\&.
  500. .RE
  501. .PP
  502. \fB\-\-amend\fR
  503. .RS 4
  504. Replace the tip of the current branch by creating a new commit\&. The recorded tree is prepared as usual (including the effect of the
  505. \fB\-i\fR
  506. and
  507. \fB\-o\fR
  508. options and explicit pathspec), and the message from the original commit is used as the starting point, instead of an empty message, when no other message is specified from the command line via options such as
  509. \fB\-m\fR,
  510. \fB\-F\fR,
  511. \fB\-c\fR, etc\&. The new commit has the same parents and author as the current one (the
  512. \fB\-\-reset\-author\fR
  513. option can countermand this)\&.
  514. .sp
  515. It is a rough equivalent for:
  516. .sp
  517. .if n \{\
  518. .RS 4
  519. .\}
  520. .nf
  521. $ git reset \-\-soft HEAD^
  522. $ \&.\&.\&. do something else to come up with the right tree \&.\&.\&.
  523. $ git commit \-c ORIG_HEAD
  524. .fi
  525. .if n \{\
  526. .RE
  527. .\}
  528. .sp
  529. but can be used to amend a merge commit\&.
  530. .sp
  531. You should understand the implications of rewriting history if you amend a commit that has already been published\&. (See the "RECOVERING FROM UPSTREAM REBASE" section in
  532. \fBgit-rebase\fR(1)\&.)
  533. .RE
  534. .PP
  535. \fB\-\-no\-post\-rewrite\fR
  536. .RS 4
  537. Bypass the
  538. \fBpost\-rewrite\fR
  539. hook\&.
  540. .RE
  541. .PP
  542. \fB\-i\fR, \fB\-\-include\fR
  543. .RS 4
  544. Before making a commit out of staged contents so far, stage the contents of paths given on the command line as well\&. This is usually not what you want unless you are concluding a conflicted merge\&.
  545. .RE
  546. .PP
  547. \fB\-o\fR, \fB\-\-only\fR
  548. .RS 4
  549. Make a commit by taking the updated working tree contents of the paths specified on the command line, disregarding any contents that have been staged for other paths\&. This is the default mode of operation of
  550. \fBgit\fR
  551. \fBcommit\fR
  552. if any paths are given on the command line, in which case this option can be omitted\&. If this option is specified together with
  553. \fB\-\-amend\fR, then no paths need to be specified, which can be used to amend the last commit without committing changes that have already been staged\&. If used together with
  554. \fB\-\-allow\-empty\fR
  555. paths are also not required, and an empty commit will be created\&.
  556. .RE
  557. .PP
  558. \fB\-\-pathspec\-from\-file=\fR\fI<file>\fR
  559. .RS 4
  560. Pass pathspec in
  561. \fI<file>\fR
  562. instead of commandline args\&. If
  563. \fI<file>\fR
  564. is exactly
  565. \fB\-\fR
  566. then standard input is used\&. Pathspec elements are separated by
  567. \fILF\fR
  568. or
  569. \fICR\fR/\fILF\fR\&. Pathspec elements can be quoted as explained for the configuration variable
  570. \fBcore\&.quotePath\fR
  571. (see
  572. \fBgit-config\fR(1))\&. See also
  573. \fB\-\-pathspec\-file\-nul\fR
  574. and global
  575. \fB\-\-literal\-pathspecs\fR\&.
  576. .RE
  577. .PP
  578. \fB\-\-pathspec\-file\-nul\fR
  579. .RS 4
  580. Only meaningful with
  581. \fB\-\-pathspec\-from\-file\fR\&. Pathspec elements are separated with
  582. \fINUL\fR
  583. character and all other characters are taken literally (including newlines and quotes)\&.
  584. .RE
  585. .PP
  586. \fB\-u\fR[\fI<mode>\fR], \fB\-\-untracked\-files\fR[\fB=\fR\fI<mode>\fR]
  587. .RS 4
  588. Show untracked files\&.
  589. .sp
  590. The
  591. \fI<mode>\fR
  592. parameter is optional (defaults to
  593. \fBall\fR), and is used to specify the handling of untracked files; when
  594. \fB\-u\fR
  595. is not used, the default is
  596. \fBnormal\fR, i\&.e\&. show untracked files and directories\&.
  597. .sp
  598. The possible options are:
  599. .PP
  600. \fBno\fR
  601. .RS 4
  602. Show no untracked files
  603. .RE
  604. .PP
  605. \fBnormal\fR
  606. .RS 4
  607. Shows untracked files and directories
  608. .RE
  609. .PP
  610. \fBall\fR
  611. .RS 4
  612. Also shows individual files in untracked directories\&.
  613. .RE
  614. .sp
  615. All usual spellings for Boolean value
  616. \fBtrue\fR
  617. are taken as
  618. \fBnormal\fR
  619. and
  620. \fBfalse\fR
  621. as
  622. \fBno\fR\&. The default can be changed using the
  623. \fBstatus\&.showUntrackedFiles\fR
  624. configuration variable documented in
  625. \fBgit-config\fR(1)\&.
  626. .RE
  627. .PP
  628. \fB\-v\fR, \fB\-\-verbose\fR
  629. .RS 4
  630. Show unified diff between the
  631. \fBHEAD\fR
  632. commit and what would be committed at the bottom of the commit message template to help the user describe the commit by reminding what changes the commit has\&. Note that this diff output doesn\(cqt have its lines prefixed with #\&. This diff will not be a part of the commit message\&. See the
  633. \fBcommit\&.verbose\fR
  634. configuration variable in
  635. \fBgit-config\fR(1)\&.
  636. .sp
  637. If specified twice, show in addition the unified diff between what would be committed and the worktree files, i\&.e\&. the unstaged changes to tracked files\&.
  638. .RE
  639. .PP
  640. \fB\-q\fR, \fB\-\-quiet\fR
  641. .RS 4
  642. Suppress commit summary message\&.
  643. .RE
  644. .PP
  645. \fB\-\-dry\-run\fR
  646. .RS 4
  647. Do not create a commit, but show a list of paths that are to be committed, paths with local changes that will be left uncommitted and paths that are untracked\&.
  648. .RE
  649. .PP
  650. \fB\-\-status\fR
  651. .RS 4
  652. Include the output of
  653. \fBgit-status\fR(1)
  654. in the commit message template when using an editor to prepare the commit message\&. Defaults to on, but can be used to override configuration variable
  655. \fBcommit\&.status\fR\&.
  656. .RE
  657. .PP
  658. \fB\-\-no\-status\fR
  659. .RS 4
  660. Do not include the output of
  661. \fBgit-status\fR(1)
  662. in the commit message template when using an editor to prepare the default commit message\&.
  663. .RE
  664. .PP
  665. \fB\-S\fR[\fI<key\-id>\fR], \fB\-\-gpg\-sign\fR[\fB=\fR\fI<key\-id>\fR], \fB\-\-no\-gpg\-sign\fR
  666. .RS 4
  667. GPG\-sign commits\&. The
  668. \fI<key\-id>\fR
  669. is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space\&.
  670. \fB\-\-no\-gpg\-sign\fR
  671. is useful to countermand both
  672. \fBcommit\&.gpgSign\fR
  673. configuration variable, and earlier
  674. \fB\-\-gpg\-sign\fR\&.
  675. .RE
  676. .PP
  677. \fB\-\-\fR
  678. .RS 4
  679. Do not interpret any more arguments as options\&.
  680. .RE
  681. .PP
  682. \fI<pathspec>\fR\&.\&.\&.
  683. .RS 4
  684. When
  685. \fI<pathspec>\fR
  686. is given on the command line, commit the contents of the files that match the pathspec without recording the changes already added to the index\&. The contents of these files are also staged for the next commit on top of what have been staged before\&.
  687. .sp
  688. For more details, see the
  689. \fIpathspec\fR
  690. entry in
  691. \fBgitglossary\fR(7)\&.
  692. .RE
  693. .SH "EXAMPLES"
  694. .sp
  695. When recording your own work, the contents of modified files in your working tree are temporarily stored to a staging area called the "index" with \fBgit\fR \fBadd\fR\&. A file can be reverted back, only in the index but not in the working tree, to that of the last commit with \fBgit\fR \fBrestore\fR \fB\-\-staged\fR \fI<file>\fR, which effectively reverts \fBgit\fR \fBadd\fR and prevents the changes to this file from participating in the next commit\&. After building the state to be committed incrementally with these commands, \fBgit\fR \fBcommit\fR (without any pathname parameter) is used to record what has been staged so far\&. This is the most basic form of the command\&. An example:
  696. .sp
  697. .if n \{\
  698. .RS 4
  699. .\}
  700. .nf
  701. $ edit hello\&.c
  702. $ git rm goodbye\&.c
  703. $ git add hello\&.c
  704. $ git commit
  705. .fi
  706. .if n \{\
  707. .RE
  708. .\}
  709. .sp
  710. Instead of staging files after each individual change, you can tell \fBgit\fR \fBcommit\fR to notice the changes to the files whose contents are tracked in your working tree and do corresponding \fBgit\fR \fBadd\fR and \fBgit\fR \fBrm\fR for you\&. That is, this example does the same as the earlier example if there is no other change in your working tree:
  711. .sp
  712. .if n \{\
  713. .RS 4
  714. .\}
  715. .nf
  716. $ edit hello\&.c
  717. $ rm goodbye\&.c
  718. $ git commit \-a
  719. .fi
  720. .if n \{\
  721. .RE
  722. .\}
  723. .sp
  724. The command \fBgit\fR \fBcommit\fR \fB\-a\fR first looks at your working tree, notices that you have modified \fBhello\&.c\fR and removed \fBgoodbye\&.c\fR, and performs necessary \fBgit\fR \fBadd\fR and \fBgit\fR \fBrm\fR for you\&.
  725. .sp
  726. After staging changes to many files, you can alter the order the changes are recorded in, by giving pathnames to \fBgit\fR \fBcommit\fR\&. When pathnames are given, the command makes a commit that only records the changes made to the named paths:
  727. .sp
  728. .if n \{\
  729. .RS 4
  730. .\}
  731. .nf
  732. $ edit hello\&.c hello\&.h
  733. $ git add hello\&.c hello\&.h
  734. $ edit Makefile
  735. $ git commit Makefile
  736. .fi
  737. .if n \{\
  738. .RE
  739. .\}
  740. .sp
  741. This makes a commit that records the modification to \fBMakefile\fR\&. The changes staged for \fBhello\&.c\fR and \fBhello\&.h\fR are not included in the resulting commit\&. However, their changes are not lost \(em they are still staged and merely held back\&. After the above sequence, if you do:
  742. .sp
  743. .if n \{\
  744. .RS 4
  745. .\}
  746. .nf
  747. $ git commit
  748. .fi
  749. .if n \{\
  750. .RE
  751. .\}
  752. .sp
  753. this second commit would record the changes to \fBhello\&.c\fR and \fBhello\&.h\fR as expected\&.
  754. .sp
  755. After a merge (initiated by \fBgit\fR \fBmerge\fR or \fBgit\fR \fBpull\fR) stops because of conflicts, cleanly merged paths are already staged to be committed for you, and paths that conflicted are left in unmerged state\&. You would have to first check which paths are conflicting with \fBgit\fR \fBstatus\fR and after fixing them manually in your working tree, you would stage the result as usual with \fBgit\fR \fBadd\fR:
  756. .sp
  757. .if n \{\
  758. .RS 4
  759. .\}
  760. .nf
  761. $ git status | grep unmerged
  762. unmerged: hello\&.c
  763. $ edit hello\&.c
  764. $ git add hello\&.c
  765. .fi
  766. .if n \{\
  767. .RE
  768. .\}
  769. .sp
  770. After resolving conflicts and staging the result, \fBgit\fR \fBls\-files\fR \fB\-u\fR would stop mentioning the conflicted path\&. When you are done, run \fBgit\fR \fBcommit\fR to finally record the merge:
  771. .sp
  772. .if n \{\
  773. .RS 4
  774. .\}
  775. .nf
  776. $ git commit
  777. .fi
  778. .if n \{\
  779. .RE
  780. .\}
  781. .sp
  782. As with the case to record your own changes, you can use \fB\-a\fR option to save typing\&. One difference is that during a merge resolution, you cannot use \fBgit\fR \fBcommit\fR with pathnames to alter the order the changes are committed, because the merge should be recorded as a single commit\&. In fact, the command refuses to run when given pathnames (but see \fB\-i\fR option)\&.
  783. .SH "COMMIT INFORMATION"
  784. .sp
  785. Author and committer information is taken from the following environment variables, if set:
  786. .sp
  787. .RS 4
  788. .ie n \{\
  789. \h'-04'\(bu\h'+03'\c
  790. .\}
  791. .el \{\
  792. .sp -1
  793. .IP \(bu 2.3
  794. .\}
  795. \fBGIT_AUTHOR_NAME\fR
  796. .RE
  797. .sp
  798. .RS 4
  799. .ie n \{\
  800. \h'-04'\(bu\h'+03'\c
  801. .\}
  802. .el \{\
  803. .sp -1
  804. .IP \(bu 2.3
  805. .\}
  806. \fBGIT_AUTHOR_EMAIL\fR
  807. .RE
  808. .sp
  809. .RS 4
  810. .ie n \{\
  811. \h'-04'\(bu\h'+03'\c
  812. .\}
  813. .el \{\
  814. .sp -1
  815. .IP \(bu 2.3
  816. .\}
  817. \fBGIT_AUTHOR_DATE\fR
  818. .RE
  819. .sp
  820. .RS 4
  821. .ie n \{\
  822. \h'-04'\(bu\h'+03'\c
  823. .\}
  824. .el \{\
  825. .sp -1
  826. .IP \(bu 2.3
  827. .\}
  828. \fBGIT_COMMITTER_NAME\fR
  829. .RE
  830. .sp
  831. .RS 4
  832. .ie n \{\
  833. \h'-04'\(bu\h'+03'\c
  834. .\}
  835. .el \{\
  836. .sp -1
  837. .IP \(bu 2.3
  838. .\}
  839. \fBGIT_COMMITTER_EMAIL\fR
  840. .RE
  841. .sp
  842. .RS 4
  843. .ie n \{\
  844. \h'-04'\(bu\h'+03'\c
  845. .\}
  846. .el \{\
  847. .sp -1
  848. .IP \(bu 2.3
  849. .\}
  850. \fBGIT_COMMITTER_DATE\fR
  851. .RE
  852. .sp
  853. (nb "<", ">" and "\en"s are stripped)
  854. .sp
  855. The author and committer names are by convention some form of a personal name (that is, the name by which other humans refer to you), although Git does not enforce or require any particular form\&. Arbitrary Unicode may be used, subject to the constraints listed above\&. This name has no effect on authentication; for that, see the \fBcredential\&.username\fR variable in \fBgit-config\fR(1)\&.
  856. .sp
  857. In case (some of) these environment variables are not set, the information is taken from the configuration items \fBuser\&.name\fR and \fBuser\&.email\fR, or, if not present, the environment variable \fBEMAIL\fR, or, if that is not set, system user name and the hostname used for outgoing mail (taken from \fB/etc/mailname\fR and falling back to the fully qualified hostname when that file does not exist)\&.
  858. .sp
  859. The \fBauthor\&.name\fR and \fBcommitter\&.name\fR and their corresponding email options override \fBuser\&.name\fR and \fBuser\&.email\fR if set and are overridden themselves by the environment variables\&.
  860. .sp
  861. The typical usage is to set just the \fBuser\&.name\fR and \fBuser\&.email\fR variables; the other options are provided for more complex use cases\&.
  862. .SH "DATE FORMATS"
  863. .sp
  864. The \fBGIT_AUTHOR_DATE\fR and \fBGIT_COMMITTER_DATE\fR environment variables support the following date formats:
  865. .PP
  866. Git internal format
  867. .RS 4
  868. It is
  869. \fI<unix\-timestamp>\fR
  870. \fI<time\-zone\-offset>\fR, where
  871. \fI<unix\-timestamp>\fR
  872. is the number of seconds since the UNIX epoch\&.
  873. \fI<time\-zone\-offset>\fR
  874. is a positive or negative offset from UTC\&. For example CET (which is 1 hour ahead of UTC) is
  875. \fB+0100\fR\&.
  876. .RE
  877. .PP
  878. RFC 2822
  879. .RS 4
  880. The standard date format as described by RFC 2822, for example
  881. \fBThu,\fR
  882. \fB07\fR
  883. \fBApr\fR
  884. \fB2005\fR
  885. \fB22:13:13\fR
  886. \fB+0200\fR\&.
  887. .RE
  888. .PP
  889. ISO 8601
  890. .RS 4
  891. Time and date specified by the ISO 8601 standard, for example
  892. \fB2005\-04\-07T22:13:13\fR\&. The parser accepts a space instead of the
  893. \fBT\fR
  894. character as well\&. Fractional parts of a second will be ignored, for example
  895. \fB2005\-04\-07T22:13:13\&.019\fR
  896. will be treated as
  897. \fB2005\-04\-07T22:13:13\fR\&.
  898. .if n \{\
  899. .sp
  900. .\}
  901. .RS 4
  902. .it 1 an-trap
  903. .nr an-no-space-flag 1
  904. .nr an-break-flag 1
  905. .br
  906. .ps +1
  907. \fBNote\fR
  908. .ps -1
  909. .br
  910. In addition, the date part is accepted in the following formats:
  911. \fBYYYY\&.MM\&.DD\fR,
  912. \fBMM/DD/YYYY\fR
  913. and
  914. \fBDD\&.MM\&.YYYY\fR\&.
  915. .sp .5v
  916. .RE
  917. .RE
  918. .sp
  919. In addition to recognizing all date formats above, the \fB\-\-date\fR option will also try to make sense of other, more human\-centric date formats, such as relative dates like "yesterday" or "last Friday at noon"\&.
  920. .SH "DISCUSSION"
  921. .sp
  922. Though not required, it\(cqs a good idea to begin the commit message with a single short (no more than 50 characters) line summarizing the change, followed by a blank line and then a more thorough description\&. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git\&. For example, \fBgit-format-patch\fR(1) turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body\&.
  923. .sp
  924. Git is to some extent character encoding agnostic\&.
  925. .sp
  926. .RS 4
  927. .ie n \{\
  928. \h'-04'\(bu\h'+03'\c
  929. .\}
  930. .el \{\
  931. .sp -1
  932. .IP \(bu 2.3
  933. .\}
  934. The contents of the blob objects are uninterpreted sequences of bytes\&. There is no encoding translation at the core level\&.
  935. .RE
  936. .sp
  937. .RS 4
  938. .ie n \{\
  939. \h'-04'\(bu\h'+03'\c
  940. .\}
  941. .el \{\
  942. .sp -1
  943. .IP \(bu 2.3
  944. .\}
  945. Path names are encoded in UTF\-8 normalization form C\&. This applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (\&.\fBgit/config\fR
  946. (see
  947. \fBgit-config\fR(1)),
  948. \fBgitignore\fR(5),
  949. \fBgitattributes\fR(5)
  950. and
  951. \fBgitmodules\fR(5))\&.
  952. .sp
  953. Note that Git at the core level treats path names simply as sequences of non\-NUL bytes, there are no path name encoding conversions (except on Mac and Windows)\&. Therefore, using non\-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings\&. However, repositories created on such systems will not work properly on UTF\-8\-based systems (e\&.g\&. Linux, Mac, Windows) and vice versa\&. Additionally, many Git\-based tools simply assume path names to be UTF\-8 and will fail to display other encodings correctly\&.
  954. .RE
  955. .sp
  956. .RS 4
  957. .ie n \{\
  958. \h'-04'\(bu\h'+03'\c
  959. .\}
  960. .el \{\
  961. .sp -1
  962. .IP \(bu 2.3
  963. .\}
  964. Commit log messages are typically encoded in UTF\-8, but other extended ASCII encodings are also supported\&. This includes ISO\-8859\-x, CP125x and many others, but
  965. \fInot\fR
  966. UTF\-16/32, EBCDIC and CJK multi\-byte encodings (GBK, Shift\-JIS, Big5, EUC\-x, CP9xx etc\&.)\&.
  967. .RE
  968. .sp
  969. Although we encourage that the commit log messages are encoded in UTF\-8, both the core and Git Porcelain are designed not to force UTF\-8 on projects\&. If all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it\&. However, there are a few things to keep in mind\&.
  970. .sp
  971. .RS 4
  972. .ie n \{\
  973. \h'-04' 1.\h'+01'\c
  974. .\}
  975. .el \{\
  976. .sp -1
  977. .IP " 1." 4.2
  978. .\}
  979. \fBgit\fR
  980. \fBcommit\fR
  981. and
  982. \fBgit\fR
  983. \fBcommit\-tree\fR
  984. issue a warning if the commit log message given to it does not look like a valid UTF\-8 string, unless you explicitly say your project uses a legacy encoding\&. The way to say this is to have
  985. \fBi18n\&.commitEncoding\fR
  986. in \&.\fBgit/config\fR
  987. file, like this:
  988. .sp
  989. .if n \{\
  990. .RS 4
  991. .\}
  992. .nf
  993. [i18n]
  994. commitEncoding = ISO\-8859\-1
  995. .fi
  996. .if n \{\
  997. .RE
  998. .\}
  999. .sp
  1000. Commit objects created with the above setting record the value of
  1001. \fBi18n\&.commitEncoding\fR
  1002. in their
  1003. \fBencoding\fR
  1004. header\&. This is to help other people who look at them later\&. Lack of this header implies that the commit log message is encoded in UTF\-8\&.
  1005. .RE
  1006. .sp
  1007. .RS 4
  1008. .ie n \{\
  1009. \h'-04' 2.\h'+01'\c
  1010. .\}
  1011. .el \{\
  1012. .sp -1
  1013. .IP " 2." 4.2
  1014. .\}
  1015. \fBgit\fR
  1016. \fBlog\fR,
  1017. \fBgit\fR
  1018. \fBshow\fR,
  1019. \fBgit\fR
  1020. \fBblame\fR
  1021. and friends look at the
  1022. \fBencoding\fR
  1023. header of a commit object, and try to re\-code the log message into UTF\-8 unless otherwise specified\&. You can specify the desired output encoding with
  1024. \fBi18n\&.logOutputEncoding\fR
  1025. in \&.\fBgit/config\fR
  1026. file, like this:
  1027. .sp
  1028. .if n \{\
  1029. .RS 4
  1030. .\}
  1031. .nf
  1032. [i18n]
  1033. logOutputEncoding = ISO\-8859\-1
  1034. .fi
  1035. .if n \{\
  1036. .RE
  1037. .\}
  1038. .sp
  1039. If you do not have this configuration variable, the value of
  1040. \fBi18n\&.commitEncoding\fR
  1041. is used instead\&.
  1042. .RE
  1043. .sp
  1044. Note that we deliberately chose not to re\-code the commit log message when a commit is made to force UTF\-8 at the commit object level, because re\-coding to UTF\-8 is not necessarily a reversible operation\&.
  1045. .SH "ENVIRONMENT AND CONFIGURATION VARIABLES"
  1046. .sp
  1047. The editor used to edit the commit log message will be chosen from the \fBGIT_EDITOR\fR environment variable, the \fBcore\&.editor\fR configuration variable, the \fBVISUAL\fR environment variable, or the \fBEDITOR\fR environment variable (in that order)\&. See \fBgit-var\fR(1) for details\&.
  1048. .sp
  1049. Everything above this line in this section isn\(cqt included from the \fBgit-config\fR(1) documentation\&. The content that follows is the same as what\(cqs found there:
  1050. .PP
  1051. \fBcommit\&.cleanup\fR
  1052. .RS 4
  1053. This setting overrides the default of the
  1054. \fB\-\-cleanup\fR
  1055. option in
  1056. \fBgit\fR
  1057. \fBcommit\fR\&. Changing the default can be useful when you always want to keep lines that begin with the comment character # in your log message, in which case you would do
  1058. \fBgit\fR
  1059. \fBconfig\fR
  1060. \fBcommit\&.cleanup\fR
  1061. \fBwhitespace\fR
  1062. (note that you will have to remove the help lines that begin with # in the commit log template yourself, if you do this)\&.
  1063. .RE
  1064. .PP
  1065. \fBcommit\&.gpgSign\fR
  1066. .RS 4
  1067. A boolean to specify whether all commits should be GPG signed\&. Use of this option when doing operations such as rebase can result in a large number of commits being signed\&. It may be convenient to use an agent to avoid typing your GPG passphrase several times\&.
  1068. .RE
  1069. .PP
  1070. \fBcommit\&.status\fR
  1071. .RS 4
  1072. A boolean to enable/disable inclusion of status information in the commit message template when using an editor to prepare the commit message\&. Defaults to
  1073. \fBtrue\fR\&.
  1074. .RE
  1075. .PP
  1076. \fBcommit\&.template\fR
  1077. .RS 4
  1078. Specify the pathname of a file to use as the template for new commit messages\&.
  1079. .RE
  1080. .PP
  1081. \fBcommit\&.verbose\fR
  1082. .RS 4
  1083. A boolean or int to specify the level of verbosity with
  1084. \fBgit\fR
  1085. \fBcommit\fR\&.
  1086. .RE
  1087. .SH "HOOKS"
  1088. .sp
  1089. This command can run \fBcommit\-msg\fR, \fBprepare\-commit\-msg\fR, \fBpre\-commit\fR, \fBpost\-commit\fR and \fBpost\-rewrite\fR hooks\&. See \fBgithooks\fR(5) for more information\&.
  1090. .SH "FILES"
  1091. .PP
  1092. \fB$GIT_DIR/COMMIT_EDITMSG\fR
  1093. .RS 4
  1094. This file contains the commit message of a commit in progress\&. If
  1095. \fBgit\fR
  1096. \fBcommit\fR
  1097. exits due to an error before creating a commit, any commit message that has been provided by the user (e\&.g\&., in an editor session) will be available in this file, but will be overwritten by the next invocation of
  1098. \fBgit\fR
  1099. \fBcommit\fR\&.
  1100. .RE
  1101. .SH "SEE ALSO"
  1102. .sp
  1103. \fBgit-add\fR(1), \fBgit-rm\fR(1), \fBgit-mv\fR(1), \fBgit-merge\fR(1), \fBgit-commit-tree\fR(1)
  1104. .SH "GIT"
  1105. .sp
  1106. Part of the \fBgit\fR(1) suite