blob: 59f8050d0adb7af26802ab14f55070c850c01f59 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano40f2f8d2006-02-07 08:04:396<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-commit(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-commit(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-commit -
Junio C Hamano7c73c662007-01-19 00:37:50269 Record changes to the repository
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
Junio C Hamanoeb415992008-06-08 22:49:47276<div class="content"><em>git-commit</em> [-a | --interactive] [-s] [-v] [-u] [--amend]
277 [(-c | -C) &lt;commit&gt;] [-F &lt;file&gt; | -m &lt;msg&gt;]
278 [--allow-empty] [--no-verify] [-e] [--author=&lt;author&gt;]
Junio C Hamano554da792007-12-27 03:29:58279 [--cleanup=&lt;mode&gt;] [--] [[-i | -o ]&lt;file&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23280</div>
281<h2>DESCRIPTION</h2>
282<div class="sectionbody">
Junio C Hamanobd2b4bb2007-08-06 06:42:24283<p>Use <em>git commit</em> to store the current contents of the index in a new
284commit along with a log message describing the changes you have made.</p>
Junio C Hamanob515b6a2007-08-08 09:21:16285<p>The content to be added can be specified in several ways:</p>
Junio C Hamanoe7935c42006-12-13 21:32:17286<ol>
287<li>
288<p>
Junio C Hamanob515b6a2007-08-08 09:21:16289by using <a href="git-add.html">git-add(1)</a> to incrementally "add" changes to the
290 index before using the <em>commit</em> command (Note: even modified
291 files must be "added");
292</p>
293</li>
294<li>
295<p>
Junio C Hamanobd2b4bb2007-08-06 06:42:24296by using <a href="git-rm.html">git-rm(1)</a> to remove files from the working tree
297 and the index, again before using the <em>commit</em> command;
Junio C Hamanoe7935c42006-12-13 21:32:17298</p>
299</li>
300<li>
301<p>
Junio C Hamanobd2b4bb2007-08-06 06:42:24302by listing files as arguments to the <em>commit</em> command, in which
303 case the commit will ignore changes staged in the index, and instead
304 record the current content of the listed files;
Junio C Hamanoe7935c42006-12-13 21:32:17305</p>
306</li>
307<li>
308<p>
Junio C Hamanobd2b4bb2007-08-06 06:42:24309by using the -a switch with the <em>commit</em> command to automatically
310 "add" changes from all known files (i.e. all files that are already
311 listed in the index) and to automatically "rm" files in the index
312 that have been removed from the working tree, and then perform the
313 actual commit;
Junio C Hamanoe7935c42006-12-13 21:32:17314</p>
315</li>
Junio C Hamanoc51fede2007-03-12 07:29:20316<li>
317<p>
318by using the --interactive switch with the <em>commit</em> command to decide one
319 by one which files should be part of the commit, before finalizing the
320 operation. Currently, this is done by invoking <tt>git-add --interactive</tt>.
321</p>
322</li>
Junio C Hamanoe7935c42006-12-13 21:32:17323</ol>
324<p>The <a href="git-status.html">git-status(1)</a> command can be used to obtain a
325summary of what is included by any of the above for the next
326commit by giving the same set of parameters you would give to
327this command.</p>
328<p>If you make a commit and then found a mistake immediately after
329that, you can recover from it with <a href="git-reset.html">git-reset(1)</a>.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23330</div>
331<h2>OPTIONS</h2>
332<div class="sectionbody">
333<dl>
334<dt>
Junio C Hamanoeb415992008-06-08 22:49:47335-a
336</dt>
337<dt>
338--all
Junio C Hamano1a4e8412005-12-27 08:17:23339</dt>
340<dd>
341<p>
Junio C Hamanoe7935c42006-12-13 21:32:17342 Tell the command to automatically stage files that have
343 been modified and deleted, but new files you have not
344 told git about are not affected.
Junio C Hamano1a4e8412005-12-27 08:17:23345</p>
346</dd>
347<dt>
Junio C Hamanoeb415992008-06-08 22:49:47348-C &lt;commit&gt;
349</dt>
350<dt>
351--reuse-message=&lt;commit&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23352</dt>
353<dd>
354<p>
Junio C Hamanoeb415992008-06-08 22:49:47355 Take an existing commit object, and reuse the log message
Junio C Hamano1a4e8412005-12-27 08:17:23356 and the authorship information (including the timestamp)
Junio C Hamanoeb415992008-06-08 22:49:47357 when creating the commit.
358</p>
359</dd>
360<dt>
361-c &lt;commit&gt;
362</dt>
363<dt>
364--reedit-message=&lt;commit&gt;
365</dt>
366<dd>
367<p>
368 Like <em>-C</em>, but with <em>-c</em> the editor is invoked, so that
369 the user can further edit the commit message.
Junio C Hamano1a4e8412005-12-27 08:17:23370</p>
371</dd>
372<dt>
373-F &lt;file&gt;
374</dt>
Junio C Hamanoeb415992008-06-08 22:49:47375<dt>
376--file=&lt;file&gt;
377</dt>
Junio C Hamano1a4e8412005-12-27 08:17:23378<dd>
379<p>
380 Take the commit message from the given file. Use <em>-</em> to
381 read the message from the standard input.
382</p>
383</dd>
384<dt>
Junio C Hamanoeb415992008-06-08 22:49:47385--author=&lt;author&gt;
Junio C Hamano40f2f8d2006-02-07 08:04:39386</dt>
387<dd>
388<p>
389 Override the author name used in the commit. Use
390 <tt>A U Thor &lt;author@example.com&gt;</tt> format.
391</p>
392</dd>
393<dt>
Junio C Hamanoeb415992008-06-08 22:49:47394-m &lt;msg&gt;
395</dt>
396<dt>
397--message=&lt;msg&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23398</dt>
399<dd>
400<p>
401 Use the given &lt;msg&gt; as the commit message.
402</p>
403</dd>
404<dt>
Junio C Hamanoeb415992008-06-08 22:49:47405-t &lt;file&gt;
406</dt>
407<dt>
408--template=&lt;file&gt;
Junio C Hamanoa3770f92007-07-25 08:53:33409</dt>
410<dd>
411<p>
412 Use the contents of the given file as the initial version
413 of the commit message. The editor is invoked and you can
414 make subsequent changes. If a message is specified using
Junio C Hamanob968dbb2007-07-27 07:26:40415 the <tt>-m</tt> or <tt>-F</tt> options, this option has no effect. This
416 overrides the <tt>commit.template</tt> configuration variable.
Junio C Hamanoa3770f92007-07-25 08:53:33417</p>
418</dd>
419<dt>
Junio C Hamanoeb415992008-06-08 22:49:47420-s
421</dt>
422<dt>
423--signoff
Junio C Hamano1a4e8412005-12-27 08:17:23424</dt>
425<dd>
426<p>
427 Add Signed-off-by line at the end of the commit message.
428</p>
429</dd>
430<dt>
Junio C Hamanoeb415992008-06-08 22:49:47431-n
432</dt>
433<dt>
Junio C Hamanoe7935c42006-12-13 21:32:17434--no-verify
Junio C Hamano1a4e8412005-12-27 08:17:23435</dt>
436<dd>
437<p>
Junio C Hamano942b35e2007-12-09 10:19:33438 This option bypasses the pre-commit and commit-msg hooks.
Junio C Hamano2fbcd212008-05-14 22:26:07439 See also <a href="githooks.html">githooks(5)</a>[hooks].
Junio C Hamano1a4e8412005-12-27 08:17:23440</p>
441</dd>
442<dt>
Junio C Hamano0c999702007-12-03 09:57:55443--allow-empty
444</dt>
445<dd>
446<p>
447 Usually recording a commit that has the exact same tree as its
Junio C Hamano58256872007-12-04 08:31:13448 sole parent commit is a mistake, and the command prevents you
449 from making such a commit. This option bypasses the safety, and
450 is primarily for use by foreign scm interface scripts.
Junio C Hamano0c999702007-12-03 09:57:55451</p>
452</dd>
453<dt>
Junio C Hamano554da792007-12-27 03:29:58454--cleanup=&lt;mode&gt;
455</dt>
456<dd>
457<p>
458 This option sets how the commit message is cleaned up.
459 The <em>&lt;mode&gt;</em> can be one of <em>verbatim</em>, <em>whitespace</em>, <em>strip</em>,
460 and <em>default</em>. The <em>default</em> mode will strip leading and
461 trailing empty lines and #commentary from the commit message
462 only if the message is to be edited. Otherwise only whitespace
463 removed. The <em>verbatim</em> mode does not change message at all,
464 <em>whitespace</em> removes just leading/trailing whitespace lines
465 and <em>strip</em> removes both whitespace and commentary.
466</p>
467</dd>
468<dt>
Junio C Hamanoeb415992008-06-08 22:49:47469-e
470</dt>
471<dt>
472--edit
Junio C Hamano1a4e8412005-12-27 08:17:23473</dt>
474<dd>
475<p>
476 The message taken from file with <tt>-F</tt>, command line with
477 <tt>-m</tt>, and from file with <tt>-C</tt> are usually used as the
478 commit log message unmodified. This option lets you
479 further edit the message taken from these sources.
480</p>
481</dd>
482<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28483--amend
484</dt>
485<dd>
486<p>
487 Used to amend the tip of the current branch. Prepare the tree
488 object you would want to replace the latest commit as usual
489 (this includes the usual -i/-o and explicit paths), and the
490 commit log editor is seeded with the commit message from the
491 tip of the current branch. The commit you create replaces the
492 current tip &#8212; if it was a merge, it will have the parents of
493 the current tip as parents &#8212; so the current top commit is
494 discarded.
495</p>
496<p>It is a rough equivalent for:</p>
497<div class="listingblock">
498<div class="content">
499<pre><tt> $ git reset --soft HEAD^
500 $ ... do something else to come up with the right tree ...
Junio C Hamano47ea30e2006-04-05 23:08:03501 $ git commit -c ORIG_HEAD
502</tt></pre>
Junio C Hamanobfe9e752006-04-05 21:43:28503</div></div>
504<p>but can be used to amend a merge commit.</p>
505</dd>
506<dt>
Junio C Hamanoeb415992008-06-08 22:49:47507-i
508</dt>
509<dt>
510--include
Junio C Hamano40f2f8d2006-02-07 08:04:39511</dt>
512<dd>
513<p>
Junio C Hamanoe7935c42006-12-13 21:32:17514 Before making a commit out of staged contents so far,
515 stage the contents of paths given on the command line
516 as well. This is usually not what you want unless you
517 are concluding a conflicted merge.
Junio C Hamano6697ac52006-02-14 08:00:23518</p>
519</dd>
520<dt>
Junio C Hamanoeb415992008-06-08 22:49:47521-o
522</dt>
523<dt>
524--only
Junio C Hamanoe79159d2008-04-12 08:23:17525</dt>
526<dd>
527<p>
528 Make a commit only from the paths specified on the
529 command line, disregarding any contents that have been
530 staged so far. This is the default mode of operation of
531 <em>git commit</em> if any paths are given on the command line,
532 in which case this option can be omitted.
533 If this option is specified together with <em>--amend</em>, then
534 no paths need be specified, which can be used to amend
535 the last commit without committing changes that have
536 already been staged.
537</p>
538</dd>
539<dt>
Junio C Hamanoeb415992008-06-08 22:49:47540-u
541</dt>
542<dt>
543--untracked-files
Junio C Hamano1e6e0062007-07-13 05:33:25544</dt>
545<dd>
546<p>
547 Show all untracked files, also those in uninteresting
548 directories, in the "Untracked files:" section of commit
549 message template. Without this option only its name and
550 a trailing slash are displayed for each untracked
551 directory.
552</p>
553</dd>
554<dt>
Junio C Hamanoeb415992008-06-08 22:49:47555-v
556</dt>
557<dt>
558--verbose
Junio C Hamano1e6e0062007-07-13 05:33:25559</dt>
560<dd>
561<p>
562 Show unified diff between the HEAD commit and what
563 would be committed at the bottom of the commit message
564 template. Note that this diff output doesn't have its
565 lines prefixed with <em>#</em>.
566</p>
567</dd>
568<dt>
Junio C Hamanoeb415992008-06-08 22:49:47569-q
570</dt>
571<dt>
572--quiet
Junio C Hamano7d23f5e2006-12-16 07:44:04573</dt>
574<dd>
575<p>
Junio C Hamanof9771f62007-01-17 17:42:30576 Suppress commit summary message.
Junio C Hamano7d23f5e2006-12-16 07:44:04577</p>
578</dd>
579<dt>
Junio C Hamano1bb569e2006-05-05 23:14:25580--
Junio C Hamano1a4e8412005-12-27 08:17:23581</dt>
582<dd>
583<p>
584 Do not interpret any more arguments as options.
585</p>
586</dd>
587<dt>
588&lt;file&gt;&#8230;
589</dt>
590<dd>
591<p>
Junio C Hamanoe7935c42006-12-13 21:32:17592 When files are given on the command line, the command
593 commits the contents of the named files, without
594 recording the changes already staged. The contents of
595 these files are also staged for the next commit on top
596 of what have been staged before.
Junio C Hamano1a4e8412005-12-27 08:17:23597</p>
598</dd>
599</dl>
Junio C Hamano1a4e8412005-12-27 08:17:23600</div>
Junio C Hamanoe7935c42006-12-13 21:32:17601<h2>EXAMPLES</h2>
Junio C Hamano40f2f8d2006-02-07 08:04:39602<div class="sectionbody">
Junio C Hamanoe7935c42006-12-13 21:32:17603<p>When recording your own work, the contents of modified files in
604your working tree are temporarily stored to a staging area
Junio C Hamano361c1332007-11-14 12:17:22605called the "index" with <a href="git-add.html">git-add(1)</a>. A file can be
606reverted back, only in the index but not in the working tree,
607to that of the last commit with <tt>git-reset HEAD &#8212; &lt;file&gt;</tt>,
608which effectively reverts <tt>git-add</tt> and prevents the changes to
609this file from participating in the next commit. After building
610the state to be committed incrementally with these commands,
611<tt>git commit</tt> (without any pathname parameter) is used to record what
Junio C Hamanoe7935c42006-12-13 21:32:17612has been staged so far. This is the most basic form of the
613command. An example:</p>
614<div class="listingblock">
Junio C Hamano40f2f8d2006-02-07 08:04:39615<div class="content">
Junio C Hamanoe7935c42006-12-13 21:32:17616<pre><tt>$ edit hello.c
617$ git rm goodbye.c
618$ git add hello.c
619$ git commit</tt></pre>
Junio C Hamano40f2f8d2006-02-07 08:04:39620</div></div>
Junio C Hamanoe7935c42006-12-13 21:32:17621<p>Instead of staging files after each individual change, you can
622tell <tt>git commit</tt> to notice the changes to the files whose
623contents are tracked in
624your working tree and do corresponding <tt>git add</tt> and <tt>git rm</tt>
625for you. That is, this example does the same as the earlier
626example if there is no other change in your working tree:</p>
627<div class="listingblock">
628<div class="content">
629<pre><tt>$ edit hello.c
630$ rm goodbye.c
631$ git commit -a</tt></pre>
632</div></div>
633<p>The command <tt>git commit -a</tt> first looks at your working tree,
634notices that you have modified hello.c and removed goodbye.c,
635and performs necessary <tt>git add</tt> and <tt>git rm</tt> for you.</p>
636<p>After staging changes to many files, you can alter the order the
637changes are recorded in, by giving pathnames to <tt>git commit</tt>.
638When pathnames are given, the command makes a commit that
639only records the changes made to the named paths:</p>
640<div class="listingblock">
641<div class="content">
642<pre><tt>$ edit hello.c hello.h
643$ git add hello.c hello.h
644$ edit Makefile
645$ git commit Makefile</tt></pre>
646</div></div>
647<p>This makes a commit that records the modification to <tt>Makefile</tt>.
648The changes staged for <tt>hello.c</tt> and <tt>hello.h</tt> are not included
649in the resulting commit. However, their changes are not lost &#8212;
650they are still staged and merely held back. After the above
651sequence, if you do:</p>
652<div class="listingblock">
653<div class="content">
654<pre><tt>$ git commit</tt></pre>
655</div></div>
656<p>this second commit would record the changes to <tt>hello.c</tt> and
657<tt>hello.h</tt> as expected.</p>
658<p>After a merge (initiated by either <a href="git-merge.html">git-merge(1)</a> or
659<a href="git-pull.html">git-pull(1)</a>) stops because of conflicts, cleanly merged
660paths are already staged to be committed for you, and paths that
661conflicted are left in unmerged state. You would have to first
662check which paths are conflicting with <a href="git-status.html">git-status(1)</a>
663and after fixing them manually in your working tree, you would
664stage the result as usual with <a href="git-add.html">git-add(1)</a>:</p>
665<div class="listingblock">
666<div class="content">
667<pre><tt>$ git status | grep unmerged
668unmerged: hello.c
669$ edit hello.c
670$ git add hello.c</tt></pre>
671</div></div>
672<p>After resolving conflicts and staging the result, <tt>git ls-files -u</tt>
673would stop mentioning the conflicted path. When you are done,
674run <tt>git commit</tt> to finally record the merge:</p>
675<div class="listingblock">
676<div class="content">
677<pre><tt>$ git commit</tt></pre>
678</div></div>
679<p>As with the case to record your own changes, you can use <tt>-a</tt>
680option to save typing. One difference is that during a merge
681resolution, you cannot use <tt>git commit</tt> with pathnames to
682alter the order the changes are committed, because the merge
683should be recorded as a single commit. In fact, the command
684refuses to run when given pathnames (but see <tt>-i</tt> option).</p>
685</div>
Junio C Hamano775a0f42006-12-31 01:19:14686<h2>DISCUSSION</h2>
687<div class="sectionbody">
Junio C Hamano8f76dc62007-01-17 07:24:25688<p>Though not required, it's a good idea to begin the commit message
689with a single short (less than 50 character) line summarizing the
690change, followed by a blank line and then a more thorough description.
691Tools that turn commits into email, for example, use the first line
692on the Subject: line and the rest of the commit in the body.</p>
Junio C Hamano775a0f42006-12-31 01:19:14693<p>At the core level, git is character encoding agnostic.</p>
694<ul>
695<li>
696<p>
697The pathnames recorded in the index and in the tree objects
698 are treated as uninterpreted sequences of non-NUL bytes.
699 What readdir(2) returns are what are recorded and compared
700 with the data git keeps track of, which in turn are expected
701 to be what lstat(2) and creat(2) accepts. There is no such
702 thing as pathname encoding translation.
703</p>
704</li>
705<li>
706<p>
707The contents of the blob objects are uninterpreted sequence
708 of bytes. There is no encoding translation at the core
709 level.
710</p>
711</li>
712<li>
713<p>
714The commit log messages are uninterpreted sequence of non-NUL
715 bytes.
716</p>
717</li>
718</ul>
719<p>Although we encourage that the commit log messages are encoded
720in UTF-8, both the core and git Porcelain are designed not to
721force UTF-8 on projects. If all participants of a particular
722project find it more convenient to use legacy encodings, git
723does not forbid it. However, there are a few things to keep in
724mind.</p>
725<ol>
726<li>
727<p>
728<tt>git-commit-tree</tt> (hence, <tt>git-commit</tt> which uses it) issues
Junio C Hamano14b76482008-01-05 10:32:26729 a warning if the commit log message given to it does not look
Junio C Hamano775a0f42006-12-31 01:19:14730 like a valid UTF-8 string, unless you explicitly say your
731 project uses a legacy encoding. The way to say this is to
Junio C Hamano35bb3f62007-02-19 05:35:53732 have i18n.commitencoding in <tt>.git/config</tt> file, like this:
Junio C Hamano775a0f42006-12-31 01:19:14733</p>
734<div class="listingblock">
735<div class="content">
Junio C Hamano35bb3f62007-02-19 05:35:53736<pre><tt>[i18n]
Junio C Hamano775a0f42006-12-31 01:19:14737 commitencoding = ISO-8859-1</tt></pre>
738</div></div>
739<p>Commit objects created with the above setting record the value
Junio C Hamano35bb3f62007-02-19 05:35:53740of <tt>i18n.commitencoding</tt> in its <tt>encoding</tt> header. This is to
Junio C Hamano775a0f42006-12-31 01:19:14741help other people who look at them later. Lack of this header
742implies that the commit log message is encoded in UTF-8.</p>
743</li>
744<li>
745<p>
746<tt>git-log</tt>, <tt>git-show</tt> and friends looks at the <tt>encoding</tt>
747 header of a commit object, and tries to re-code the log
748 message into UTF-8 unless otherwise specified. You can
749 specify the desired output encoding with
Junio C Hamano35bb3f62007-02-19 05:35:53750 <tt>i18n.logoutputencoding</tt> in <tt>.git/config</tt> file, like this:
Junio C Hamano775a0f42006-12-31 01:19:14751</p>
752<div class="listingblock">
753<div class="content">
Junio C Hamano35bb3f62007-02-19 05:35:53754<pre><tt>[i18n]
Junio C Hamano775a0f42006-12-31 01:19:14755 logoutputencoding = ISO-8859-1</tt></pre>
756</div></div>
757<p>If you do not have this configuration variable, the value of
Junio C Hamano35bb3f62007-02-19 05:35:53758<tt>i18n.commitencoding</tt> is used instead.</p>
Junio C Hamano775a0f42006-12-31 01:19:14759</li>
760</ol>
761<p>Note that we deliberately chose not to re-code the commit log
762message when a commit is made to force UTF-8 at the commit
763object level, because re-coding to UTF-8 is not necessarily a
764reversible operation.</p>
765</div>
Junio C Hamanof6002a92007-07-20 10:28:22766<h2>ENVIRONMENT AND CONFIGURATION VARIABLES</h2>
Junio C Hamanoe7935c42006-12-13 21:32:17767<div class="sectionbody">
Junio C Hamanof6002a92007-07-20 10:28:22768<p>The editor used to edit the commit log message will be chosen from the
769GIT_EDITOR environment variable, the core.editor configuration variable, the
770VISUAL environment variable, or the EDITOR environment variable (in that
771order).</p>
Junio C Hamanoe7935c42006-12-13 21:32:17772</div>
773<h2>HOOKS</h2>
774<div class="sectionbody">
Junio C Hamano26e590a2008-02-17 03:53:51775<p>This command can run <tt>commit-msg</tt>, <tt>prepare-commit-msg</tt>, <tt>pre-commit</tt>,
Junio C Hamano2fbcd212008-05-14 22:26:07776and <tt>post-commit</tt> hooks. See <a href="githooks.html">githooks(5)</a>[hooks] for more
Junio C Hamanoe7935c42006-12-13 21:32:17777information.</p>
778</div>
779<h2>SEE ALSO</h2>
780<div class="sectionbody">
781<p><a href="git-add.html">git-add(1)</a>,
782<a href="git-rm.html">git-rm(1)</a>,
783<a href="git-mv.html">git-mv(1)</a>,
784<a href="git-merge.html">git-merge(1)</a>,
785<a href="git-commit-tree.html">git-commit-tree(1)</a></p>
Junio C Hamano40f2f8d2006-02-07 08:04:39786</div>
Junio C Hamano1a4e8412005-12-27 08:17:23787<h2>Author</h2>
788<div class="sectionbody">
789<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt; and
790Junio C Hamano &lt;junkio@cox.net&gt;</p>
791</div>
792<h2>GIT</h2>
793<div class="sectionbody">
Junio C Hamanof7c042d2008-06-06 22:50:53794<p>Part of the <a href="git.html">git(1)</a> suite</p>
Junio C Hamano1a4e8412005-12-27 08:17:23795</div>
796<div id="footer">
797<div id="footer-text">
Junio C Hamanoeb415992008-06-08 22:49:47798Last updated 08-Jun-2008 22:46:24 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23799</div>
800</div>
801</body>
802</html>