Updated git_doc to git 1.8
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-commit.xml
blobf796a61f3a37738a9e964bb0277cad4d88c2f820
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="git-commit(1)">\r
5     <title>git-commit(1)</title>\r
6 <indexterm>\r
7 <primary>git-commit(1)</primary>\r
8 </indexterm>\r
9 <simplesect id="git-commit(1)__name">\r
10 <title>NAME</title>\r
11 <simpara>git-commit - Record changes to the repository</simpara>\r
12 </simplesect>\r
13 <simplesect id="git-commit(1)__synopsis">\r
14 <title>SYNOPSIS</title>\r
15 <blockquote>\r
16 <literallayout><emphasis>git commit</emphasis> [-a | --interactive | --patch] [-s] [-v] [-u&lt;mode&gt;] [--amend]\r
17            [--dry-run] [(-c | -C | --fixup | --squash) &lt;commit&gt;]\r
18            [-F &lt;file&gt; | -m &lt;msg&gt;] [--reset-author] [--allow-empty]\r
19            [--allow-empty-message] [--no-verify] [-e] [--author=&lt;author&gt;]\r
20            [--date=&lt;date&gt;] [--cleanup=&lt;mode&gt;] [--status | --no-status]\r
21            [-i | -o] [-S[&lt;keyid&gt;]] [--] [&lt;file&gt;&#8230;]</literallayout>\r
22 </blockquote>\r
23 </simplesect>\r
24 <simplesect id="git-commit(1)__description">\r
25 <title>DESCRIPTION</title>\r
26 <simpara>Stores the current contents of the index in a new commit along\r
27 with a log message from the user describing the changes.</simpara>\r
28 <simpara>The content to be added can be specified in several ways:</simpara>\r
29 <orderedlist numeration="arabic">\r
30 <listitem>\r
31 <simpara>\r
32 by using <emphasis>git add</emphasis> to incrementally "add" changes to the\r
33    index before using the <emphasis>commit</emphasis> command (Note: even modified\r
34    files must be "added");\r
35 </simpara>\r
36 </listitem>\r
37 <listitem>\r
38 <simpara>\r
39 by using <emphasis>git rm</emphasis> to remove files from the working tree\r
40    and the index, again before using the <emphasis>commit</emphasis> command;\r
41 </simpara>\r
42 </listitem>\r
43 <listitem>\r
44 <simpara>\r
45 by listing files as arguments to the <emphasis>commit</emphasis> command, in which\r
46    case the commit will ignore changes staged in the index, and instead\r
47    record the current content of the listed files (which must already\r
48    be known to git);\r
49 </simpara>\r
50 </listitem>\r
51 <listitem>\r
52 <simpara>\r
53 by using the -a switch with the <emphasis>commit</emphasis> command to automatically\r
54    "add" changes from all known files (i.e. all files that are already\r
55    listed in the index) and to automatically "rm" files in the index\r
56    that have been removed from the working tree, and then perform the\r
57    actual commit;\r
58 </simpara>\r
59 </listitem>\r
60 <listitem>\r
61 <simpara>\r
62 by using the --interactive or --patch switches with the <emphasis>commit</emphasis> command\r
63    to decide one by one which files or hunks should be part of the commit,\r
64    before finalizing the operation. See the Interactive Mode section of\r
65    <xref linkend="git-add(1)" /> to learn how to operate these modes.\r
66 </simpara>\r
67 </listitem>\r
68 </orderedlist>\r
69 <simpara>The <emphasis>--dry-run</emphasis> option can be used to obtain a\r
70 summary of what is included by any of the above for the next\r
71 commit by giving the same set of parameters (options and paths).</simpara>\r
72 <simpara>If you make a commit and then find a mistake immediately after\r
73 that, you can recover from it with <emphasis>git reset</emphasis>.</simpara>\r
74 </simplesect>\r
75 <simplesect id="git-commit(1)__options">\r
76 <title>OPTIONS</title>\r
77 <variablelist>\r
78 <varlistentry>\r
79 <term>\r
80 -a\r
81 </term>\r
82 <term>\r
83 --all\r
84 </term>\r
85 <listitem>\r
86 <simpara>\r
87         Tell the command to automatically stage files that have\r
88         been modified and deleted, but new files you have not\r
89         told git about are not affected.\r
90 </simpara>\r
91 </listitem>\r
92 </varlistentry>\r
93 <varlistentry>\r
94 <term>\r
95 -p\r
96 </term>\r
97 <term>\r
98 --patch\r
99 </term>\r
100 <listitem>\r
101 <simpara>\r
102         Use the interactive patch selection interface to chose\r
103         which changes to commit. See <xref linkend="git-add(1)" /> for\r
104         details.\r
105 </simpara>\r
106 </listitem>\r
107 </varlistentry>\r
108 <varlistentry>\r
109 <term>\r
110 -C &lt;commit&gt;\r
111 </term>\r
112 <term>\r
113 --reuse-message=&lt;commit&gt;\r
114 </term>\r
115 <listitem>\r
116 <simpara>\r
117         Take an existing commit object, and reuse the log message\r
118         and the authorship information (including the timestamp)\r
119         when creating the commit.\r
120 </simpara>\r
121 </listitem>\r
122 </varlistentry>\r
123 <varlistentry>\r
124 <term>\r
125 -c &lt;commit&gt;\r
126 </term>\r
127 <term>\r
128 --reedit-message=&lt;commit&gt;\r
129 </term>\r
130 <listitem>\r
131 <simpara>\r
132         Like <emphasis>-C</emphasis>, but with <emphasis>-c</emphasis> the editor is invoked, so that\r
133         the user can further edit the commit message.\r
134 </simpara>\r
135 </listitem>\r
136 </varlistentry>\r
137 <varlistentry>\r
138 <term>\r
139 --fixup=&lt;commit&gt;\r
140 </term>\r
141 <listitem>\r
142 <simpara>\r
143         Construct a commit message for use with <emphasis>rebase --autosquash</emphasis>.\r
144         The commit message will be the subject line from the specified\r
145         commit with a prefix of "fixup! ".  See <xref linkend="git-rebase(1)" />\r
146         for details.\r
147 </simpara>\r
148 </listitem>\r
149 </varlistentry>\r
150 <varlistentry>\r
151 <term>\r
152 --squash=&lt;commit&gt;\r
153 </term>\r
154 <listitem>\r
155 <simpara>\r
156         Construct a commit message for use with <emphasis>rebase --autosquash</emphasis>.\r
157         The commit message subject line is taken from the specified\r
158         commit with a prefix of "squash! ".  Can be used with additional\r
159         commit message options (<emphasis>-m</emphasis>/<emphasis>-c</emphasis>/<emphasis>-C</emphasis>/<emphasis>-F</emphasis>). See\r
160         <xref linkend="git-rebase(1)" /> for details.\r
161 </simpara>\r
162 </listitem>\r
163 </varlistentry>\r
164 <varlistentry>\r
165 <term>\r
166 --reset-author\r
167 </term>\r
168 <listitem>\r
169 <simpara>\r
170         When used with -C/-c/--amend options, or when committing after a\r
171         a conflicting cherry-pick, declare that the authorship of the\r
172         resulting commit now belongs of the committer. This also renews\r
173         the author timestamp.\r
174 </simpara>\r
175 </listitem>\r
176 </varlistentry>\r
177 <varlistentry>\r
178 <term>\r
179 --short\r
180 </term>\r
181 <listitem>\r
182 <simpara>\r
183         When doing a dry-run, give the output in the short-format. See\r
184         <xref linkend="git-status(1)" /> for details. Implies <emphasis>--dry-run</emphasis>.\r
185 </simpara>\r
186 </listitem>\r
187 </varlistentry>\r
188 <varlistentry>\r
189 <term>\r
190 --branch\r
191 </term>\r
192 <listitem>\r
193 <simpara>\r
194         Show the branch and tracking info even in short-format.\r
195 </simpara>\r
196 </listitem>\r
197 </varlistentry>\r
198 <varlistentry>\r
199 <term>\r
200 --porcelain\r
201 </term>\r
202 <listitem>\r
203 <simpara>\r
204         When doing a dry-run, give the output in a porcelain-ready\r
205         format. See <xref linkend="git-status(1)" /> for details. Implies\r
206         <emphasis>--dry-run</emphasis>.\r
207 </simpara>\r
208 </listitem>\r
209 </varlistentry>\r
210 <varlistentry>\r
211 <term>\r
212 --long\r
213 </term>\r
214 <listitem>\r
215 <simpara>\r
216         When doing a dry-run, give the output in a the long-format.\r
217         Implies <emphasis>--dry-run</emphasis>.\r
218 </simpara>\r
219 </listitem>\r
220 </varlistentry>\r
221 <varlistentry>\r
222 <term>\r
223 -z\r
224 </term>\r
225 <term>\r
226 --null\r
227 </term>\r
228 <listitem>\r
229 <simpara>\r
230         When showing <emphasis>short</emphasis> or <emphasis>porcelain</emphasis> status output, terminate\r
231         entries in the status output with NUL, instead of LF. If no\r
232         format is given, implies the <emphasis>--porcelain</emphasis> output format.\r
233 </simpara>\r
234 </listitem>\r
235 </varlistentry>\r
236 <varlistentry>\r
237 <term>\r
238 -F &lt;file&gt;\r
239 </term>\r
240 <term>\r
241 --file=&lt;file&gt;\r
242 </term>\r
243 <listitem>\r
244 <simpara>\r
245         Take the commit message from the given file.  Use <emphasis>-</emphasis> to\r
246         read the message from the standard input.\r
247 </simpara>\r
248 </listitem>\r
249 </varlistentry>\r
250 <varlistentry>\r
251 <term>\r
252 --author=&lt;author&gt;\r
253 </term>\r
254 <listitem>\r
255 <simpara>\r
256         Override the commit author. Specify an explicit author using the\r
257         standard <emphasis>A U Thor &lt;author@example.com&gt;</emphasis> format. Otherwise &lt;author&gt;\r
258         is assumed to be a pattern and is used to search for an existing\r
259         commit by that author (i.e. rev-list --all -i --author=&lt;author&gt;);\r
260         the commit author is then copied from the first such commit found.\r
261 </simpara>\r
262 </listitem>\r
263 </varlistentry>\r
264 <varlistentry>\r
265 <term>\r
266 --date=&lt;date&gt;\r
267 </term>\r
268 <listitem>\r
269 <simpara>\r
270         Override the author date used in the commit.\r
271 </simpara>\r
272 </listitem>\r
273 </varlistentry>\r
274 <varlistentry>\r
275 <term>\r
276 -m &lt;msg&gt;\r
277 </term>\r
278 <term>\r
279 --message=&lt;msg&gt;\r
280 </term>\r
281 <listitem>\r
282 <simpara>\r
283         Use the given &lt;msg&gt; as the commit message.\r
284 </simpara>\r
285 </listitem>\r
286 </varlistentry>\r
287 <varlistentry>\r
288 <term>\r
289 -t &lt;file&gt;\r
290 </term>\r
291 <term>\r
292 --template=&lt;file&gt;\r
293 </term>\r
294 <listitem>\r
295 <simpara>\r
296         When editing the commit message, start the editor with the\r
297         contents in the given file.  The <emphasis>commit.template</emphasis> configuration\r
298         variable is often used to give this option implicitly to the\r
299         command.  This mechanism can be used by projects that want to\r
300         guide participants with some hints on what to write in the message\r
301         in what order.  If the user exits the editor without editing the\r
302         message, the commit is aborted.  This has no effect when a message\r
303         is given by other means, e.g. with the <emphasis>-m</emphasis> or <emphasis>-F</emphasis> options.\r
304 </simpara>\r
305 </listitem>\r
306 </varlistentry>\r
307 <varlistentry>\r
308 <term>\r
309 -s\r
310 </term>\r
311 <term>\r
312 --signoff\r
313 </term>\r
314 <listitem>\r
315 <simpara>\r
316         Add Signed-off-by line by the committer at the end of the commit\r
317         log message.\r
318 </simpara>\r
319 </listitem>\r
320 </varlistentry>\r
321 <varlistentry>\r
322 <term>\r
323 -n\r
324 </term>\r
325 <term>\r
326 --no-verify\r
327 </term>\r
328 <listitem>\r
329 <simpara>\r
330         This option bypasses the pre-commit and commit-msg hooks.\r
331         See also <xref linkend="githooks(5)" />.\r
332 </simpara>\r
333 </listitem>\r
334 </varlistentry>\r
335 <varlistentry>\r
336 <term>\r
337 --allow-empty\r
338 </term>\r
339 <listitem>\r
340 <simpara>\r
341         Usually recording a commit that has the exact same tree as its\r
342         sole parent commit is a mistake, and the command prevents you\r
343         from making such a commit.  This option bypasses the safety, and\r
344         is primarily for use by foreign SCM interface scripts.\r
345 </simpara>\r
346 </listitem>\r
347 </varlistentry>\r
348 <varlistentry>\r
349 <term>\r
350 --allow-empty-message\r
351 </term>\r
352 <listitem>\r
353 <simpara>\r
354        Like --allow-empty this command is primarily for use by foreign\r
355        SCM interface scripts. It allows you to create a commit with an\r
356        empty commit message without using plumbing commands like\r
357        <xref linkend="git-commit-tree(1)" />.\r
358 </simpara>\r
359 </listitem>\r
360 </varlistentry>\r
361 <varlistentry>\r
362 <term>\r
363 --cleanup=&lt;mode&gt;\r
364 </term>\r
365 <listitem>\r
366 <simpara>\r
367         This option sets how the commit message is cleaned up.\r
368         The  <emphasis>&lt;mode&gt;</emphasis> can be one of <emphasis>verbatim</emphasis>, <emphasis>whitespace</emphasis>, <emphasis>strip</emphasis>,\r
369         and <emphasis>default</emphasis>. The <emphasis>default</emphasis> mode will strip leading and\r
370         trailing empty lines and #commentary from the commit message\r
371         only if the message is to be edited. Otherwise only whitespace\r
372         removed. The <emphasis>verbatim</emphasis> mode does not change message at all,\r
373         <emphasis>whitespace</emphasis> removes just leading/trailing whitespace lines\r
374         and <emphasis>strip</emphasis> removes both whitespace and commentary.\r
375 </simpara>\r
376 </listitem>\r
377 </varlistentry>\r
378 <varlistentry>\r
379 <term>\r
380 -e\r
381 </term>\r
382 <term>\r
383 --edit\r
384 </term>\r
385 <listitem>\r
386 <simpara>\r
387         The message taken from file with <emphasis>-F</emphasis>, command line with\r
388         <emphasis>-m</emphasis>, and from file with <emphasis>-C</emphasis> are usually used as the\r
389         commit log message unmodified.  This option lets you\r
390         further edit the message taken from these sources.\r
391 </simpara>\r
392 </listitem>\r
393 </varlistentry>\r
394 <varlistentry>\r
395 <term>\r
396 --no-edit\r
397 </term>\r
398 <listitem>\r
399 <simpara>\r
400         Use the selected commit message without launching an editor.\r
401         For example, <emphasis>git commit --amend --no-edit</emphasis> amends a commit\r
402         without changing its commit message.\r
403 </simpara>\r
404 </listitem>\r
405 </varlistentry>\r
406 <varlistentry>\r
407 <term>\r
408 --amend\r
409 </term>\r
410 <listitem>\r
411 <simpara>\r
412         Used to amend the tip of the current branch. Prepare the tree\r
413         object you would want to replace the latest commit as usual\r
414         (this includes the usual -i/-o and explicit paths), and the\r
415         commit log editor is seeded with the commit message from the\r
416         tip of the current branch. The commit you create replaces the\r
417         current tip -- if it was a merge, it will have the parents of\r
418         the current tip as parents -- so the current top commit is\r
419         discarded.\r
420 </simpara>\r
421 <simpara>It is a rough equivalent for:</simpara>\r
422 <screen>        $ git reset --soft HEAD^\r
423         $ ... do something else to come up with the right tree ...\r
424         $ git commit -c ORIG_HEAD</screen>\r
425 <simpara>but can be used to amend a merge commit.</simpara>\r
426 <simpara>You should understand the implications of rewriting history if you\r
427 amend a commit that has already been published.  (See the "RECOVERING\r
428 FROM UPSTREAM REBASE" section in <xref linkend="git-rebase(1)" />.)</simpara>\r
429 </listitem>\r
430 </varlistentry>\r
431 <varlistentry>\r
432 <term>\r
433 --no-post-rewrite\r
434 </term>\r
435 <listitem>\r
436 <simpara>\r
437         Bypass the post-rewrite hook.\r
438 </simpara>\r
439 </listitem>\r
440 </varlistentry>\r
441 <varlistentry>\r
442 <term>\r
443 -i\r
444 </term>\r
445 <term>\r
446 --include\r
447 </term>\r
448 <listitem>\r
449 <simpara>\r
450         Before making a commit out of staged contents so far,\r
451         stage the contents of paths given on the command line\r
452         as well.  This is usually not what you want unless you\r
453         are concluding a conflicted merge.\r
454 </simpara>\r
455 </listitem>\r
456 </varlistentry>\r
457 <varlistentry>\r
458 <term>\r
459 -o\r
460 </term>\r
461 <term>\r
462 --only\r
463 </term>\r
464 <listitem>\r
465 <simpara>\r
466         Make a commit only from the paths specified on the\r
467         command line, disregarding any contents that have been\r
468         staged so far. This is the default mode of operation of\r
469         <emphasis>git commit</emphasis> if any paths are given on the command line,\r
470         in which case this option can be omitted.\r
471         If this option is specified together with <emphasis>--amend</emphasis>, then\r
472         no paths need to be specified, which can be used to amend\r
473         the last commit without committing changes that have\r
474         already been staged.\r
475 </simpara>\r
476 </listitem>\r
477 </varlistentry>\r
478 <varlistentry>\r
479 <term>\r
480 -u[&lt;mode&gt;]\r
481 </term>\r
482 <term>\r
483 --untracked-files[=&lt;mode&gt;]\r
484 </term>\r
485 <listitem>\r
486 <simpara>\r
487         Show untracked files.\r
488 </simpara>\r
489 <simpara>The mode parameter is optional (defaults to <emphasis>all</emphasis>), and is used to\r
490 specify the handling of untracked files; when -u is not used, the\r
491 default is <emphasis>normal</emphasis>, i.e. show untracked files and directories.</simpara>\r
492 <simpara>The possible options are:</simpara>\r
493 <itemizedlist>\r
494 <listitem>\r
495 <simpara>\r
496 <emphasis>no</emphasis>     - Show no untracked files\r
497 </simpara>\r
498 </listitem>\r
499 <listitem>\r
500 <simpara>\r
501 <emphasis>normal</emphasis> - Shows untracked files and directories\r
502 </simpara>\r
503 </listitem>\r
504 <listitem>\r
505 <simpara>\r
506 <emphasis>all</emphasis>    - Also shows individual files in untracked directories.\r
507 </simpara>\r
508 <simpara>The default can be changed using the status.showUntrackedFiles\r
509 configuration variable documented in <xref linkend="git-config(1)" />.</simpara>\r
510 </listitem>\r
511 </itemizedlist>\r
512 </listitem>\r
513 </varlistentry>\r
514 <varlistentry>\r
515 <term>\r
516 -v\r
517 </term>\r
518 <term>\r
519 --verbose\r
520 </term>\r
521 <listitem>\r
522 <simpara>\r
523         Show unified diff between the HEAD commit and what\r
524         would be committed at the bottom of the commit message\r
525         template.  Note that this diff output doesn't have its\r
526         lines prefixed with <emphasis>#</emphasis>.\r
527 </simpara>\r
528 </listitem>\r
529 </varlistentry>\r
530 <varlistentry>\r
531 <term>\r
532 -q\r
533 </term>\r
534 <term>\r
535 --quiet\r
536 </term>\r
537 <listitem>\r
538 <simpara>\r
539         Suppress commit summary message.\r
540 </simpara>\r
541 </listitem>\r
542 </varlistentry>\r
543 <varlistentry>\r
544 <term>\r
545 --dry-run\r
546 </term>\r
547 <listitem>\r
548 <simpara>\r
549         Do not create a commit, but show a list of paths that are\r
550         to be committed, paths with local changes that will be left\r
551         uncommitted and paths that are untracked.\r
552 </simpara>\r
553 </listitem>\r
554 </varlistentry>\r
555 <varlistentry>\r
556 <term>\r
557 --status\r
558 </term>\r
559 <listitem>\r
560 <simpara>\r
561         Include the output of <xref linkend="git-status(1)" /> in the commit\r
562         message template when using an editor to prepare the commit\r
563         message.  Defaults to on, but can be used to override\r
564         configuration variable commit.status.\r
565 </simpara>\r
566 </listitem>\r
567 </varlistentry>\r
568 <varlistentry>\r
569 <term>\r
570 --no-status\r
571 </term>\r
572 <listitem>\r
573 <simpara>\r
574         Do not include the output of <xref linkend="git-status(1)" /> in the\r
575         commit message template when using an editor to prepare the\r
576         default commit message.\r
577 </simpara>\r
578 </listitem>\r
579 </varlistentry>\r
580 <varlistentry>\r
581 <term>\r
582 -S[&lt;keyid&gt;]\r
583 </term>\r
584 <term>\r
585 --gpg-sign[=&lt;keyid&gt;]\r
586 </term>\r
587 <listitem>\r
588 <simpara>\r
589         GPG-sign commit.\r
590 </simpara>\r
591 </listitem>\r
592 </varlistentry>\r
593 <varlistentry>\r
594 <term>\r
595 --\r
596 </term>\r
597 <listitem>\r
598 <simpara>\r
599         Do not interpret any more arguments as options.\r
600 </simpara>\r
601 </listitem>\r
602 </varlistentry>\r
603 <varlistentry>\r
604 <term>\r
605 &lt;file&gt;&#8230;\r
606 </term>\r
607 <listitem>\r
608 <simpara>\r
609         When files are given on the command line, the command\r
610         commits the contents of the named files, without\r
611         recording the changes already staged.  The contents of\r
612         these files are also staged for the next commit on top\r
613         of what have been staged before.\r
614 </simpara>\r
615 </listitem>\r
616 </varlistentry>\r
617 </variablelist>\r
618 </simplesect>\r
619 <simplesect id="git-commit(1)__date_formats">\r
620 <title>DATE FORMATS</title>\r
621 <simpara>The GIT_AUTHOR_DATE, GIT_COMMITTER_DATE environment variables\r
622 and the <emphasis>--date</emphasis> option\r
623 support the following date formats:</simpara>\r
624 <variablelist>\r
625 <varlistentry>\r
626 <term>\r
627 Git internal format\r
628 </term>\r
629 <listitem>\r
630 <simpara>\r
631         It is <emphasis>&lt;unix timestamp&gt; &lt;timezone offset&gt;</emphasis>, where <emphasis>&lt;unix\r
632         timestamp&gt;</emphasis> is the number of seconds since the UNIX epoch.\r
633         <emphasis>&lt;timezone offset&gt;</emphasis> is a positive or negative offset from UTC.\r
634         For example CET (which is 2 hours ahead UTC) is <emphasis>+0200</emphasis>.\r
635 </simpara>\r
636 </listitem>\r
637 </varlistentry>\r
638 <varlistentry>\r
639 <term>\r
640 RFC 2822\r
641 </term>\r
642 <listitem>\r
643 <simpara>\r
644         The standard email format as described by RFC 2822, for example\r
645         <emphasis>Thu, 07 Apr 2005 22:13:13 +0200</emphasis>.\r
646 </simpara>\r
647 </listitem>\r
648 </varlistentry>\r
649 <varlistentry>\r
650 <term>\r
651 ISO 8601\r
652 </term>\r
653 <listitem>\r
654 <simpara>\r
655         Time and date specified by the ISO 8601 standard, for example\r
656         <emphasis>2005-04-07T22:13:13</emphasis>. The parser accepts a space instead of the\r
657         <emphasis>T</emphasis> character as well.\r
658 </simpara>\r
659 <note><simpara>In addition, the date part is accepted in the following formats:\r
660 <emphasis>YYYY.MM.DD</emphasis>, <emphasis>MM/DD/YYYY</emphasis> and <emphasis>DD.MM.YYYY</emphasis>.</simpara></note>\r
661 </listitem>\r
662 </varlistentry>\r
663 </variablelist>\r
664 </simplesect>\r
665 <simplesect id="git-commit(1)__examples">\r
666 <title>EXAMPLES</title>\r
667 <simpara>When recording your own work, the contents of modified files in\r
668 your working tree are temporarily stored to a staging area\r
669 called the "index" with <emphasis>git add</emphasis>.  A file can be\r
670 reverted back, only in the index but not in the working tree,\r
671 to that of the last commit with <emphasis>git reset HEAD -- &lt;file&gt;</emphasis>,\r
672 which effectively reverts <emphasis>git add</emphasis> and prevents the changes to\r
673 this file from participating in the next commit.  After building\r
674 the state to be committed incrementally with these commands,\r
675 <emphasis>git commit</emphasis> (without any pathname parameter) is used to record what\r
676 has been staged so far.  This is the most basic form of the\r
677 command.  An example:</simpara>\r
678 <screen>$ edit hello.c\r
679 $ git rm goodbye.c\r
680 $ git add hello.c\r
681 $ git commit</screen>\r
682 <simpara>Instead of staging files after each individual change, you can\r
683 tell <emphasis>git commit</emphasis> to notice the changes to the files whose\r
684 contents are tracked in\r
685 your working tree and do corresponding <emphasis>git add</emphasis> and <emphasis>git rm</emphasis>\r
686 for you.  That is, this example does the same as the earlier\r
687 example if there is no other change in your working tree:</simpara>\r
688 <screen>$ edit hello.c\r
689 $ rm goodbye.c\r
690 $ git commit -a</screen>\r
691 <simpara>The command <emphasis>git commit -a</emphasis> first looks at your working tree,\r
692 notices that you have modified hello.c and removed goodbye.c,\r
693 and performs necessary <emphasis>git add</emphasis> and <emphasis>git rm</emphasis> for you.</simpara>\r
694 <simpara>After staging changes to many files, you can alter the order the\r
695 changes are recorded in, by giving pathnames to <emphasis>git commit</emphasis>.\r
696 When pathnames are given, the command makes a commit that\r
697 only records the changes made to the named paths:</simpara>\r
698 <screen>$ edit hello.c hello.h\r
699 $ git add hello.c hello.h\r
700 $ edit Makefile\r
701 $ git commit Makefile</screen>\r
702 <simpara>This makes a commit that records the modification to <emphasis>Makefile</emphasis>.\r
703 The changes staged for <emphasis>hello.c</emphasis> and <emphasis>hello.h</emphasis> are not included\r
704 in the resulting commit.  However, their changes are not lost --\r
705 they are still staged and merely held back.  After the above\r
706 sequence, if you do:</simpara>\r
707 <screen>$ git commit</screen>\r
708 <simpara>this second commit would record the changes to <emphasis>hello.c</emphasis> and\r
709 <emphasis>hello.h</emphasis> as expected.</simpara>\r
710 <simpara>After a merge (initiated by <emphasis>git merge</emphasis> or <emphasis>git pull</emphasis>) stops\r
711 because of conflicts, cleanly merged\r
712 paths are already staged to be committed for you, and paths that\r
713 conflicted are left in unmerged state.  You would have to first\r
714 check which paths are conflicting with <emphasis>git status</emphasis>\r
715 and after fixing them manually in your working tree, you would\r
716 stage the result as usual with <emphasis>git add</emphasis>:</simpara>\r
717 <screen>$ git status | grep unmerged\r
718 unmerged: hello.c\r
719 $ edit hello.c\r
720 $ git add hello.c</screen>\r
721 <simpara>After resolving conflicts and staging the result, <emphasis>git ls-files -u</emphasis>\r
722 would stop mentioning the conflicted path.  When you are done,\r
723 run <emphasis>git commit</emphasis> to finally record the merge:</simpara>\r
724 <screen>$ git commit</screen>\r
725 <simpara>As with the case to record your own changes, you can use <emphasis>-a</emphasis>\r
726 option to save typing.  One difference is that during a merge\r
727 resolution, you cannot use <emphasis>git commit</emphasis> with pathnames to\r
728 alter the order the changes are committed, because the merge\r
729 should be recorded as a single commit.  In fact, the command\r
730 refuses to run when given pathnames (but see <emphasis>-i</emphasis> option).</simpara>\r
731 </simplesect>\r
732 <simplesect id="git-commit(1)__discussion">\r
733 <title>DISCUSSION</title>\r
734 <simpara>Though not required, it's a good idea to begin the commit message\r
735 with a single short (less than 50 character) line summarizing the\r
736 change, followed by a blank line and then a more thorough description.\r
737 The text up to the first blank line in a commit message is treated\r
738 as the commit title, and that title is used throughout git.\r
739 For example, <xref linkend="git-format-patch(1)" /> turns a commit into email, and it uses\r
740 the title on the Subject line and the rest of the commit in the body.</simpara>\r
741 <simpara>At the core level, git is character encoding agnostic.</simpara>\r
742 <itemizedlist>\r
743 <listitem>\r
744 <simpara>\r
745 The pathnames recorded in the index and in the tree objects\r
746    are treated as uninterpreted sequences of non-NUL bytes.\r
747    What readdir(2) returns are what are recorded and compared\r
748    with the data git keeps track of, which in turn are expected\r
749    to be what lstat(2) and creat(2) accepts.  There is no such\r
750    thing as pathname encoding translation.\r
751 </simpara>\r
752 </listitem>\r
753 <listitem>\r
754 <simpara>\r
755 The contents of the blob objects are uninterpreted sequences\r
756    of bytes.  There is no encoding translation at the core\r
757    level.\r
758 </simpara>\r
759 </listitem>\r
760 <listitem>\r
761 <simpara>\r
762 The commit log messages are uninterpreted sequences of non-NUL\r
763    bytes.\r
764 </simpara>\r
765 </listitem>\r
766 </itemizedlist>\r
767 <simpara>Although we encourage that the commit log messages are encoded\r
768 in UTF-8, both the core and git Porcelain are designed not to\r
769 force UTF-8 on projects.  If all participants of a particular\r
770 project find it more convenient to use legacy encodings, git\r
771 does not forbid it.  However, there are a few things to keep in\r
772 mind.</simpara>\r
773 <orderedlist numeration="arabic">\r
774 <listitem>\r
775 <simpara>\r
776 <emphasis>git commit</emphasis> and <emphasis>git commit-tree</emphasis> issues\r
777   a warning if the commit log message given to it does not look\r
778   like a valid UTF-8 string, unless you explicitly say your\r
779   project uses a legacy encoding.  The way to say this is to\r
780   have i18n.commitencoding in <emphasis>.git/config</emphasis> file, like this:\r
781 </simpara>\r
782 <screen>[i18n]\r
783         commitencoding = ISO-8859-1</screen>\r
784 <simpara>Commit objects created with the above setting record the value\r
785 of <emphasis>i18n.commitencoding</emphasis> in its <emphasis>encoding</emphasis> header.  This is to\r
786 help other people who look at them later.  Lack of this header\r
787 implies that the commit log message is encoded in UTF-8.</simpara>\r
788 </listitem>\r
789 <listitem>\r
790 <simpara>\r
791 <emphasis>git log</emphasis>, <emphasis>git show</emphasis>, <emphasis>git blame</emphasis> and friends look at the\r
792   <emphasis>encoding</emphasis> header of a commit object, and try to re-code the\r
793   log message into UTF-8 unless otherwise specified.  You can\r
794   specify the desired output encoding with\r
795   <emphasis>i18n.logoutputencoding</emphasis> in <emphasis>.git/config</emphasis> file, like this:\r
796 </simpara>\r
797 <screen>[i18n]\r
798         logoutputencoding = ISO-8859-1</screen>\r
799 <simpara>If you do not have this configuration variable, the value of\r
800 <emphasis>i18n.commitencoding</emphasis> is used instead.</simpara>\r
801 </listitem>\r
802 </orderedlist>\r
803 <simpara>Note that we deliberately chose not to re-code the commit log\r
804 message when a commit is made to force UTF-8 at the commit\r
805 object level, because re-coding to UTF-8 is not necessarily a\r
806 reversible operation.</simpara>\r
807 </simplesect>\r
808 <simplesect id="git-commit(1)__environment_and_configuration_variables">\r
809 <title>ENVIRONMENT AND CONFIGURATION VARIABLES</title>\r
810 <simpara>The editor used to edit the commit log message will be chosen from the\r
811 GIT_EDITOR environment variable, the core.editor configuration variable, the\r
812 VISUAL environment variable, or the EDITOR environment variable (in that\r
813 order).  See <xref linkend="git-var(1)" /> for details.</simpara>\r
814 </simplesect>\r
815 <simplesect id="git-commit(1)__hooks">\r
816 <title>HOOKS</title>\r
817 <simpara>This command can run <emphasis>commit-msg</emphasis>, <emphasis>prepare-commit-msg</emphasis>, <emphasis>pre-commit</emphasis>,\r
818 and <emphasis>post-commit</emphasis> hooks.  See <xref linkend="githooks(5)" /> for more\r
819 information.</simpara>\r
820 </simplesect>\r
821 <simplesect id="git-commit(1)__files">\r
822 <title>FILES</title>\r
823 <variablelist>\r
824 <varlistentry>\r
825 <term>\r
826 <emphasis>$GIT_DIR/COMMIT_EDITMSG</emphasis>\r
827 </term>\r
828 <listitem>\r
829 <simpara>\r
830         This file contains the commit message of a commit in progress.\r
831         If <emphasis>git commit</emphasis> exits due to an error before creating a commit,\r
832         any commit message that has been provided by the user (e.g., in\r
833         an editor session) will be available in this file, but will be\r
834         overwritten by the next invocation of <emphasis>git commit</emphasis>.\r
835 </simpara>\r
836 </listitem>\r
837 </varlistentry>\r
838 </variablelist>\r
839 </simplesect>\r
840 <simplesect id="git-commit(1)__see_also">\r
841 <title>SEE ALSO</title>\r
842 <simpara><xref linkend="git-add(1)" />,\r
843 <xref linkend="git-rm(1)" />,\r
844 <xref linkend="git-mv(1)" />,\r
845 <xref linkend="git-merge(1)" />,\r
846 <xref linkend="git-commit-tree(1)" /></simpara>\r
847 </simplesect>\r
848 <simplesect id="git-commit(1)__git">\r
849 <title>GIT</title>\r
850 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
851 </simplesect>\r
852 </sect2>\r