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