blob: 087aa3ef7fe2c5a6cb58329dc1c1e8d98dd152dc [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 -
269 Record your changes
270</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 Hamano6697ac52006-02-14 08:00:23276<div class="content"><em>git-commit</em> [-a] [-s] [-v] [(-c | -C) &lt;commit&gt; | -F &lt;file&gt; | -m &lt;msg&gt;]
Junio C Hamanobfe9e752006-04-05 21:43:28277 [--no-verify] [--amend] [-e] [--author &lt;author&gt;]
278 [--] [[-i | -o ]&lt;file&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23279</div>
280<h2>DESCRIPTION</h2>
281<div class="sectionbody">
Junio C Hamanoe7935c42006-12-13 21:32:17282<p>Use <em>git commit</em> when you want to record your changes into the repository
283along with a log message describing what the commit is about. All changes
284to be committed must be explicitly identified using one of the following
285methods:</p>
286<ol>
287<li>
288<p>
289by using <a href="git-add.html">git-add(1)</a> to incrementally "add" changes to the
290 next commit before using the <em>commit</em> command (Note: even modified
291 files must be "added");
292</p>
293</li>
294<li>
295<p>
296by using <a href="git-rm.html">git-rm(1)</a> to identify content removal for the next
297 commit, again before using the <em>commit</em> command;
298</p>
299</li>
300<li>
301<p>
302by directly listing files containing changes to be committed as arguments
303 to the <em>commit</em> command, in which cases only those files alone will be
304 considered for the commit;
305</p>
306</li>
307<li>
308<p>
309by using the -a switch with the <em>commit</em> command to automatically "add"
310 changes from all known files i.e. files that have already been committed
311 before, and perform the actual commit.
312</p>
313</li>
314</ol>
315<p>The <a href="git-status.html">git-status(1)</a> command can be used to obtain a
316summary of what is included by any of the above for the next
317commit by giving the same set of parameters you would give to
318this command.</p>
319<p>If you make a commit and then found a mistake immediately after
320that, you can recover from it with <a href="git-reset.html">git-reset(1)</a>.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23321</div>
322<h2>OPTIONS</h2>
323<div class="sectionbody">
324<dl>
325<dt>
326-a|--all
327</dt>
328<dd>
329<p>
Junio C Hamanoe7935c42006-12-13 21:32:17330 Tell the command to automatically stage files that have
331 been modified and deleted, but new files you have not
332 told git about are not affected.
Junio C Hamano1a4e8412005-12-27 08:17:23333</p>
334</dd>
335<dt>
336-c or -C &lt;commit&gt;
337</dt>
338<dd>
339<p>
340 Take existing commit object, and reuse the log message
341 and the authorship information (including the timestamp)
342 when creating the commit. With <em>-C</em>, the editor is not
343 invoked; with <em>-c</em> the user can further edit the commit
344 message.
345</p>
346</dd>
347<dt>
348-F &lt;file&gt;
349</dt>
350<dd>
351<p>
352 Take the commit message from the given file. Use <em>-</em> to
353 read the message from the standard input.
354</p>
355</dd>
356<dt>
Junio C Hamano40f2f8d2006-02-07 08:04:39357--author &lt;author&gt;
358</dt>
359<dd>
360<p>
361 Override the author name used in the commit. Use
362 <tt>A U Thor &lt;author@example.com&gt;</tt> format.
363</p>
364</dd>
365<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23366-m &lt;msg&gt;
367</dt>
368<dd>
369<p>
370 Use the given &lt;msg&gt; as the commit message.
371</p>
372</dd>
373<dt>
374-s|--signoff
375</dt>
376<dd>
377<p>
378 Add Signed-off-by line at the end of the commit message.
379</p>
380</dd>
381<dt>
Junio C Hamanoe7935c42006-12-13 21:32:17382--no-verify
Junio C Hamano1a4e8412005-12-27 08:17:23383</dt>
384<dd>
385<p>
Junio C Hamanoe7935c42006-12-13 21:32:17386 By default, the command looks for suspicious lines the
387 commit introduces, and aborts committing if there is one.
388 The definition of <em>suspicious lines</em> is currently the
389 lines that has trailing whitespaces, and the lines whose
390 indentation has a SP character immediately followed by a
391 TAB character. This option turns off the check.
Junio C Hamano1a4e8412005-12-27 08:17:23392</p>
393</dd>
394<dt>
395-e|--edit
396</dt>
397<dd>
398<p>
399 The message taken from file with <tt>-F</tt>, command line with
400 <tt>-m</tt>, and from file with <tt>-C</tt> are usually used as the
401 commit log message unmodified. This option lets you
402 further edit the message taken from these sources.
403</p>
404</dd>
405<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28406--amend
407</dt>
408<dd>
409<p>
410 Used to amend the tip of the current branch. Prepare the tree
411 object you would want to replace the latest commit as usual
412 (this includes the usual -i/-o and explicit paths), and the
413 commit log editor is seeded with the commit message from the
414 tip of the current branch. The commit you create replaces the
415 current tip &#8212; if it was a merge, it will have the parents of
416 the current tip as parents &#8212; so the current top commit is
417 discarded.
418</p>
419<p>It is a rough equivalent for:</p>
420<div class="listingblock">
421<div class="content">
422<pre><tt> $ git reset --soft HEAD^
423 $ ... do something else to come up with the right tree ...
Junio C Hamano47ea30e2006-04-05 23:08:03424 $ git commit -c ORIG_HEAD
425</tt></pre>
Junio C Hamanobfe9e752006-04-05 21:43:28426</div></div>
427<p>but can be used to amend a merge commit.</p>
428</dd>
429<dt>
Junio C Hamano40f2f8d2006-02-07 08:04:39430-i|--include
431</dt>
432<dd>
433<p>
Junio C Hamanoe7935c42006-12-13 21:32:17434 Before making a commit out of staged contents so far,
435 stage the contents of paths given on the command line
436 as well. This is usually not what you want unless you
437 are concluding a conflicted merge.
Junio C Hamano6697ac52006-02-14 08:00:23438</p>
439</dd>
440<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04441-q|--quiet
442</dt>
443<dd>
444<p>
445 Supress commit summary message.
446</p>
447</dd>
448<dt>
Junio C Hamano1bb569e2006-05-05 23:14:25449--
Junio C Hamano1a4e8412005-12-27 08:17:23450</dt>
451<dd>
452<p>
453 Do not interpret any more arguments as options.
454</p>
455</dd>
456<dt>
457&lt;file&gt;&#8230;
458</dt>
459<dd>
460<p>
Junio C Hamanoe7935c42006-12-13 21:32:17461 When files are given on the command line, the command
462 commits the contents of the named files, without
463 recording the changes already staged. The contents of
464 these files are also staged for the next commit on top
465 of what have been staged before.
Junio C Hamano1a4e8412005-12-27 08:17:23466</p>
467</dd>
468</dl>
Junio C Hamano1a4e8412005-12-27 08:17:23469</div>
Junio C Hamanoe7935c42006-12-13 21:32:17470<h2>EXAMPLES</h2>
Junio C Hamano40f2f8d2006-02-07 08:04:39471<div class="sectionbody">
Junio C Hamanoe7935c42006-12-13 21:32:17472<p>When recording your own work, the contents of modified files in
473your working tree are temporarily stored to a staging area
474called the "index" with <a href="git-add.html">git-add(1)</a>. Removal
475of a file is staged with <a href="git-rm.html">git-rm(1)</a>. After building the
476state to be committed incrementally with these commands, <tt>git
477commit</tt> (without any pathname parameter) is used to record what
478has been staged so far. This is the most basic form of the
479command. An example:</p>
480<div class="listingblock">
Junio C Hamano40f2f8d2006-02-07 08:04:39481<div class="content">
Junio C Hamanoe7935c42006-12-13 21:32:17482<pre><tt>$ edit hello.c
483$ git rm goodbye.c
484$ git add hello.c
485$ git commit</tt></pre>
Junio C Hamano40f2f8d2006-02-07 08:04:39486</div></div>
Junio C Hamanoe7935c42006-12-13 21:32:17487<p>Instead of staging files after each individual change, you can
488tell <tt>git commit</tt> to notice the changes to the files whose
489contents are tracked in
490your working tree and do corresponding <tt>git add</tt> and <tt>git rm</tt>
491for you. That is, this example does the same as the earlier
492example if there is no other change in your working tree:</p>
493<div class="listingblock">
494<div class="content">
495<pre><tt>$ edit hello.c
496$ rm goodbye.c
497$ git commit -a</tt></pre>
498</div></div>
499<p>The command <tt>git commit -a</tt> first looks at your working tree,
500notices that you have modified hello.c and removed goodbye.c,
501and performs necessary <tt>git add</tt> and <tt>git rm</tt> for you.</p>
502<p>After staging changes to many files, you can alter the order the
503changes are recorded in, by giving pathnames to <tt>git commit</tt>.
504When pathnames are given, the command makes a commit that
505only records the changes made to the named paths:</p>
506<div class="listingblock">
507<div class="content">
508<pre><tt>$ edit hello.c hello.h
509$ git add hello.c hello.h
510$ edit Makefile
511$ git commit Makefile</tt></pre>
512</div></div>
513<p>This makes a commit that records the modification to <tt>Makefile</tt>.
514The changes staged for <tt>hello.c</tt> and <tt>hello.h</tt> are not included
515in the resulting commit. However, their changes are not lost &#8212;
516they are still staged and merely held back. After the above
517sequence, if you do:</p>
518<div class="listingblock">
519<div class="content">
520<pre><tt>$ git commit</tt></pre>
521</div></div>
522<p>this second commit would record the changes to <tt>hello.c</tt> and
523<tt>hello.h</tt> as expected.</p>
524<p>After a merge (initiated by either <a href="git-merge.html">git-merge(1)</a> or
525<a href="git-pull.html">git-pull(1)</a>) stops because of conflicts, cleanly merged
526paths are already staged to be committed for you, and paths that
527conflicted are left in unmerged state. You would have to first
528check which paths are conflicting with <a href="git-status.html">git-status(1)</a>
529and after fixing them manually in your working tree, you would
530stage the result as usual with <a href="git-add.html">git-add(1)</a>:</p>
531<div class="listingblock">
532<div class="content">
533<pre><tt>$ git status | grep unmerged
534unmerged: hello.c
535$ edit hello.c
536$ git add hello.c</tt></pre>
537</div></div>
538<p>After resolving conflicts and staging the result, <tt>git ls-files -u</tt>
539would stop mentioning the conflicted path. When you are done,
540run <tt>git commit</tt> to finally record the merge:</p>
541<div class="listingblock">
542<div class="content">
543<pre><tt>$ git commit</tt></pre>
544</div></div>
545<p>As with the case to record your own changes, you can use <tt>-a</tt>
546option to save typing. One difference is that during a merge
547resolution, you cannot use <tt>git commit</tt> with pathnames to
548alter the order the changes are committed, because the merge
549should be recorded as a single commit. In fact, the command
550refuses to run when given pathnames (but see <tt>-i</tt> option).</p>
551</div>
552<h2>ENVIRONMENT VARIABLES</h2>
553<div class="sectionbody">
554<p>The command specified by either the VISUAL or EDITOR environment
555variables is used to edit the commit log message.</p>
556</div>
557<h2>HOOKS</h2>
558<div class="sectionbody">
559<p>This command can run <tt>commit-msg</tt>, <tt>pre-commit</tt>, and
560<tt>post-commit</tt> hooks. See <a href="hooks.html">hooks</a> for more
561information.</p>
562</div>
563<h2>SEE ALSO</h2>
564<div class="sectionbody">
565<p><a href="git-add.html">git-add(1)</a>,
566<a href="git-rm.html">git-rm(1)</a>,
567<a href="git-mv.html">git-mv(1)</a>,
568<a href="git-merge.html">git-merge(1)</a>,
569<a href="git-commit-tree.html">git-commit-tree(1)</a></p>
Junio C Hamano40f2f8d2006-02-07 08:04:39570</div>
Junio C Hamano1a4e8412005-12-27 08:17:23571<h2>Author</h2>
572<div class="sectionbody">
573<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt; and
574Junio C Hamano &lt;junkio@cox.net&gt;</p>
575</div>
576<h2>GIT</h2>
577<div class="sectionbody">
578<p>Part of the <a href="git.html">git(7)</a> suite</p>
579</div>
580<div id="footer">
581<div id="footer-text">
Junio C Hamano7d23f5e2006-12-16 07:44:04582Last updated 16-Dec-2006 07:43:46 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23583</div>
584</div>
585</body>
586</html>