blob: dd7e58c6d4494aa20705d2eff378b49ee5bc3c62 [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 Hamanoc51fede2007-03-12 07:29:20276<div class="content"><em>git-commit</em> [-a | --interactive] [-s] [-v]
277 [(-c | -C) &lt;commit&gt; | -F &lt;file&gt; | -m &lt;msg&gt; | --amend]
278 [--no-verify] [-e] [--author &lt;author&gt;]
Junio C Hamanobfe9e752006-04-05 21:43:28279 [--] [[-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 Hamanoe7935c42006-12-13 21:32:17283<p>Use <em>git commit</em> when you want to record your changes into the repository
284along with a log message describing what the commit is about. All changes
285to be committed must be explicitly identified using one of the following
286methods:</p>
287<ol>
288<li>
289<p>
290by using <a href="git-add.html">git-add(1)</a> to incrementally "add" changes to the
291 next commit before using the <em>commit</em> command (Note: even modified
292 files must be "added");
293</p>
294</li>
295<li>
296<p>
297by using <a href="git-rm.html">git-rm(1)</a> to identify content removal for the next
298 commit, again before using the <em>commit</em> command;
299</p>
300</li>
301<li>
302<p>
303by directly listing files containing changes to be committed as arguments
304 to the <em>commit</em> command, in which cases only those files alone will be
305 considered for the commit;
306</p>
307</li>
308<li>
309<p>
310by using the -a switch with the <em>commit</em> command to automatically "add"
311 changes from all known files i.e. files that have already been committed
Junio C Hamanoffaf0e22007-01-13 22:18:22312 before, and to automatically "rm" files that have been
313 removed from the working tree, and perform the 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>
335-a|--all
336</dt>
337<dd>
338<p>
Junio C Hamanoe7935c42006-12-13 21:32:17339 Tell the command to automatically stage files that have
340 been modified and deleted, but new files you have not
341 told git about are not affected.
Junio C Hamano1a4e8412005-12-27 08:17:23342</p>
343</dd>
344<dt>
345-c or -C &lt;commit&gt;
346</dt>
347<dd>
348<p>
349 Take existing commit object, and reuse the log message
350 and the authorship information (including the timestamp)
351 when creating the commit. With <em>-C</em>, the editor is not
352 invoked; with <em>-c</em> the user can further edit the commit
353 message.
354</p>
355</dd>
356<dt>
357-F &lt;file&gt;
358</dt>
359<dd>
360<p>
361 Take the commit message from the given file. Use <em>-</em> to
362 read the message from the standard input.
363</p>
364</dd>
365<dt>
Junio C Hamano40f2f8d2006-02-07 08:04:39366--author &lt;author&gt;
367</dt>
368<dd>
369<p>
370 Override the author name used in the commit. Use
371 <tt>A U Thor &lt;author@example.com&gt;</tt> format.
372</p>
373</dd>
374<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23375-m &lt;msg&gt;
376</dt>
377<dd>
378<p>
379 Use the given &lt;msg&gt; as the commit message.
380</p>
381</dd>
382<dt>
383-s|--signoff
384</dt>
385<dd>
386<p>
387 Add Signed-off-by line at the end of the commit message.
388</p>
389</dd>
390<dt>
Junio C Hamanoe7935c42006-12-13 21:32:17391--no-verify
Junio C Hamano1a4e8412005-12-27 08:17:23392</dt>
393<dd>
394<p>
Junio C Hamano24351a82007-01-13 08:09:17395 This option bypasses the pre-commit hook.
396 See also <a href="hooks.html">hooks</a>.
Junio C Hamano1a4e8412005-12-27 08:17:23397</p>
398</dd>
399<dt>
400-e|--edit
401</dt>
402<dd>
403<p>
404 The message taken from file with <tt>-F</tt>, command line with
405 <tt>-m</tt>, and from file with <tt>-C</tt> are usually used as the
406 commit log message unmodified. This option lets you
407 further edit the message taken from these sources.
408</p>
409</dd>
410<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28411--amend
412</dt>
413<dd>
414<p>
415 Used to amend the tip of the current branch. Prepare the tree
416 object you would want to replace the latest commit as usual
417 (this includes the usual -i/-o and explicit paths), and the
418 commit log editor is seeded with the commit message from the
419 tip of the current branch. The commit you create replaces the
420 current tip &#8212; if it was a merge, it will have the parents of
421 the current tip as parents &#8212; so the current top commit is
422 discarded.
423</p>
424<p>It is a rough equivalent for:</p>
425<div class="listingblock">
426<div class="content">
427<pre><tt> $ git reset --soft HEAD^
428 $ ... do something else to come up with the right tree ...
Junio C Hamano47ea30e2006-04-05 23:08:03429 $ git commit -c ORIG_HEAD
430</tt></pre>
Junio C Hamanobfe9e752006-04-05 21:43:28431</div></div>
432<p>but can be used to amend a merge commit.</p>
433</dd>
434<dt>
Junio C Hamano40f2f8d2006-02-07 08:04:39435-i|--include
436</dt>
437<dd>
438<p>
Junio C Hamanoe7935c42006-12-13 21:32:17439 Before making a commit out of staged contents so far,
440 stage the contents of paths given on the command line
441 as well. This is usually not what you want unless you
442 are concluding a conflicted merge.
Junio C Hamano6697ac52006-02-14 08:00:23443</p>
444</dd>
445<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04446-q|--quiet
447</dt>
448<dd>
449<p>
Junio C Hamanof9771f62007-01-17 17:42:30450 Suppress commit summary message.
Junio C Hamano7d23f5e2006-12-16 07:44:04451</p>
452</dd>
453<dt>
Junio C Hamano1bb569e2006-05-05 23:14:25454--
Junio C Hamano1a4e8412005-12-27 08:17:23455</dt>
456<dd>
457<p>
458 Do not interpret any more arguments as options.
459</p>
460</dd>
461<dt>
462&lt;file&gt;&#8230;
463</dt>
464<dd>
465<p>
Junio C Hamanoe7935c42006-12-13 21:32:17466 When files are given on the command line, the command
467 commits the contents of the named files, without
468 recording the changes already staged. The contents of
469 these files are also staged for the next commit on top
470 of what have been staged before.
Junio C Hamano1a4e8412005-12-27 08:17:23471</p>
472</dd>
473</dl>
Junio C Hamano1a4e8412005-12-27 08:17:23474</div>
Junio C Hamanoe7935c42006-12-13 21:32:17475<h2>EXAMPLES</h2>
Junio C Hamano40f2f8d2006-02-07 08:04:39476<div class="sectionbody">
Junio C Hamanoe7935c42006-12-13 21:32:17477<p>When recording your own work, the contents of modified files in
478your working tree are temporarily stored to a staging area
479called the "index" with <a href="git-add.html">git-add(1)</a>. Removal
480of a file is staged with <a href="git-rm.html">git-rm(1)</a>. After building the
481state to be committed incrementally with these commands, <tt>git
482commit</tt> (without any pathname parameter) is used to record what
483has been staged so far. This is the most basic form of the
484command. An example:</p>
485<div class="listingblock">
Junio C Hamano40f2f8d2006-02-07 08:04:39486<div class="content">
Junio C Hamanoe7935c42006-12-13 21:32:17487<pre><tt>$ edit hello.c
488$ git rm goodbye.c
489$ git add hello.c
490$ git commit</tt></pre>
Junio C Hamano40f2f8d2006-02-07 08:04:39491</div></div>
Junio C Hamanoe7935c42006-12-13 21:32:17492<p>Instead of staging files after each individual change, you can
493tell <tt>git commit</tt> to notice the changes to the files whose
494contents are tracked in
495your working tree and do corresponding <tt>git add</tt> and <tt>git rm</tt>
496for you. That is, this example does the same as the earlier
497example if there is no other change in your working tree:</p>
498<div class="listingblock">
499<div class="content">
500<pre><tt>$ edit hello.c
501$ rm goodbye.c
502$ git commit -a</tt></pre>
503</div></div>
504<p>The command <tt>git commit -a</tt> first looks at your working tree,
505notices that you have modified hello.c and removed goodbye.c,
506and performs necessary <tt>git add</tt> and <tt>git rm</tt> for you.</p>
507<p>After staging changes to many files, you can alter the order the
508changes are recorded in, by giving pathnames to <tt>git commit</tt>.
509When pathnames are given, the command makes a commit that
510only records the changes made to the named paths:</p>
511<div class="listingblock">
512<div class="content">
513<pre><tt>$ edit hello.c hello.h
514$ git add hello.c hello.h
515$ edit Makefile
516$ git commit Makefile</tt></pre>
517</div></div>
518<p>This makes a commit that records the modification to <tt>Makefile</tt>.
519The changes staged for <tt>hello.c</tt> and <tt>hello.h</tt> are not included
520in the resulting commit. However, their changes are not lost &#8212;
521they are still staged and merely held back. After the above
522sequence, if you do:</p>
523<div class="listingblock">
524<div class="content">
525<pre><tt>$ git commit</tt></pre>
526</div></div>
527<p>this second commit would record the changes to <tt>hello.c</tt> and
528<tt>hello.h</tt> as expected.</p>
529<p>After a merge (initiated by either <a href="git-merge.html">git-merge(1)</a> or
530<a href="git-pull.html">git-pull(1)</a>) stops because of conflicts, cleanly merged
531paths are already staged to be committed for you, and paths that
532conflicted are left in unmerged state. You would have to first
533check which paths are conflicting with <a href="git-status.html">git-status(1)</a>
534and after fixing them manually in your working tree, you would
535stage the result as usual with <a href="git-add.html">git-add(1)</a>:</p>
536<div class="listingblock">
537<div class="content">
538<pre><tt>$ git status | grep unmerged
539unmerged: hello.c
540$ edit hello.c
541$ git add hello.c</tt></pre>
542</div></div>
543<p>After resolving conflicts and staging the result, <tt>git ls-files -u</tt>
544would stop mentioning the conflicted path. When you are done,
545run <tt>git commit</tt> to finally record the merge:</p>
546<div class="listingblock">
547<div class="content">
548<pre><tt>$ git commit</tt></pre>
549</div></div>
550<p>As with the case to record your own changes, you can use <tt>-a</tt>
551option to save typing. One difference is that during a merge
552resolution, you cannot use <tt>git commit</tt> with pathnames to
553alter the order the changes are committed, because the merge
554should be recorded as a single commit. In fact, the command
555refuses to run when given pathnames (but see <tt>-i</tt> option).</p>
556</div>
Junio C Hamano775a0f42006-12-31 01:19:14557<h2>DISCUSSION</h2>
558<div class="sectionbody">
Junio C Hamano8f76dc62007-01-17 07:24:25559<p>Though not required, it's a good idea to begin the commit message
560with a single short (less than 50 character) line summarizing the
561change, followed by a blank line and then a more thorough description.
562Tools that turn commits into email, for example, use the first line
563on the Subject: line and the rest of the commit in the body.</p>
Junio C Hamano775a0f42006-12-31 01:19:14564<p>At the core level, git is character encoding agnostic.</p>
565<ul>
566<li>
567<p>
568The pathnames recorded in the index and in the tree objects
569 are treated as uninterpreted sequences of non-NUL bytes.
570 What readdir(2) returns are what are recorded and compared
571 with the data git keeps track of, which in turn are expected
572 to be what lstat(2) and creat(2) accepts. There is no such
573 thing as pathname encoding translation.
574</p>
575</li>
576<li>
577<p>
578The contents of the blob objects are uninterpreted sequence
579 of bytes. There is no encoding translation at the core
580 level.
581</p>
582</li>
583<li>
584<p>
585The commit log messages are uninterpreted sequence of non-NUL
586 bytes.
587</p>
588</li>
589</ul>
590<p>Although we encourage that the commit log messages are encoded
591in UTF-8, both the core and git Porcelain are designed not to
592force UTF-8 on projects. If all participants of a particular
593project find it more convenient to use legacy encodings, git
594does not forbid it. However, there are a few things to keep in
595mind.</p>
596<ol>
597<li>
598<p>
599<tt>git-commit-tree</tt> (hence, <tt>git-commit</tt> which uses it) issues
600 an warning if the commit log message given to it does not look
601 like a valid UTF-8 string, unless you explicitly say your
602 project uses a legacy encoding. The way to say this is to
Junio C Hamano35bb3f62007-02-19 05:35:53603 have i18n.commitencoding in <tt>.git/config</tt> file, like this:
Junio C Hamano775a0f42006-12-31 01:19:14604</p>
605<div class="listingblock">
606<div class="content">
Junio C Hamano35bb3f62007-02-19 05:35:53607<pre><tt>[i18n]
Junio C Hamano775a0f42006-12-31 01:19:14608 commitencoding = ISO-8859-1</tt></pre>
609</div></div>
610<p>Commit objects created with the above setting record the value
Junio C Hamano35bb3f62007-02-19 05:35:53611of <tt>i18n.commitencoding</tt> in its <tt>encoding</tt> header. This is to
Junio C Hamano775a0f42006-12-31 01:19:14612help other people who look at them later. Lack of this header
613implies that the commit log message is encoded in UTF-8.</p>
614</li>
615<li>
616<p>
617<tt>git-log</tt>, <tt>git-show</tt> and friends looks at the <tt>encoding</tt>
618 header of a commit object, and tries to re-code the log
619 message into UTF-8 unless otherwise specified. You can
620 specify the desired output encoding with
Junio C Hamano35bb3f62007-02-19 05:35:53621 <tt>i18n.logoutputencoding</tt> in <tt>.git/config</tt> file, like this:
Junio C Hamano775a0f42006-12-31 01:19:14622</p>
623<div class="listingblock">
624<div class="content">
Junio C Hamano35bb3f62007-02-19 05:35:53625<pre><tt>[i18n]
Junio C Hamano775a0f42006-12-31 01:19:14626 logoutputencoding = ISO-8859-1</tt></pre>
627</div></div>
628<p>If you do not have this configuration variable, the value of
Junio C Hamano35bb3f62007-02-19 05:35:53629<tt>i18n.commitencoding</tt> is used instead.</p>
Junio C Hamano775a0f42006-12-31 01:19:14630</li>
631</ol>
632<p>Note that we deliberately chose not to re-code the commit log
633message when a commit is made to force UTF-8 at the commit
634object level, because re-coding to UTF-8 is not necessarily a
635reversible operation.</p>
636</div>
Junio C Hamanoe7935c42006-12-13 21:32:17637<h2>ENVIRONMENT VARIABLES</h2>
638<div class="sectionbody">
639<p>The command specified by either the VISUAL or EDITOR environment
640variables is used to edit the commit log message.</p>
641</div>
642<h2>HOOKS</h2>
643<div class="sectionbody">
644<p>This command can run <tt>commit-msg</tt>, <tt>pre-commit</tt>, and
645<tt>post-commit</tt> hooks. See <a href="hooks.html">hooks</a> for more
646information.</p>
647</div>
648<h2>SEE ALSO</h2>
649<div class="sectionbody">
650<p><a href="git-add.html">git-add(1)</a>,
651<a href="git-rm.html">git-rm(1)</a>,
652<a href="git-mv.html">git-mv(1)</a>,
653<a href="git-merge.html">git-merge(1)</a>,
654<a href="git-commit-tree.html">git-commit-tree(1)</a></p>
Junio C Hamano40f2f8d2006-02-07 08:04:39655</div>
Junio C Hamano1a4e8412005-12-27 08:17:23656<h2>Author</h2>
657<div class="sectionbody">
658<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt; and
659Junio C Hamano &lt;junkio@cox.net&gt;</p>
660</div>
661<h2>GIT</h2>
662<div class="sectionbody">
663<p>Part of the <a href="git.html">git(7)</a> suite</p>
664</div>
665<div id="footer">
666<div id="footer-text">
Junio C Hamano20f64da2007-04-04 18:38:30667Last updated 04-Apr-2007 18:33:34 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23668</div>
669</div>
670</body>
671</html>