Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | <!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 Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 7.0.2" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, 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 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#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 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.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 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.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 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | include::./stylesheets/xhtml11-manpage.css[] |
| 230 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 231 | |
| 232 | div.sidebar-content { |
| 233 | background: #ffffee; |
| 234 | border: 1px solid silver; |
| 235 | padding: 0.5em; |
| 236 | } |
| 237 | div.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 | |
| 244 | div.listingblock div.content { |
| 245 | border: 1px solid silver; |
| 246 | background: #f4f4f4; |
| 247 | padding: 0.5em; |
| 248 | } |
| 249 | |
| 250 | div.quoteblock-content { |
| 251 | padding-left: 2.0em; |
| 252 | } |
| 253 | |
| 254 | div.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> |
| 264 | git-commit(1) Manual Page |
| 265 | </h1> |
| 266 | <h2>NAME</h2> |
| 267 | <div class="sectionbody"> |
| 268 | <p>git-commit - |
Junio C Hamano | 7c73c66 | 2007-01-19 00:37:50 | [diff] [blame] | 269 | Record changes to the repository |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 270 | </p> |
| 271 | </div> |
| 272 | </div> |
| 273 | <h2>SYNOPSIS</h2> |
| 274 | <div class="sectionbody"> |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 275 | <div class="verseblock"> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 276 | <div class="content"><em>git-commit</em> [-a | --interactive] [-s] [-v] [-u] [--amend] |
| 277 | [(-c | -C) <commit>] [-F <file> | -m <msg>] |
| 278 | [--allow-empty] [--no-verify] [-e] [--author=<author>] |
Junio C Hamano | 554da79 | 2007-12-27 03:29:58 | [diff] [blame] | 279 | [--cleanup=<mode>] [--] [[-i | -o ]<file>…]</div></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 280 | </div> |
| 281 | <h2>DESCRIPTION</h2> |
| 282 | <div class="sectionbody"> |
Junio C Hamano | bd2b4bb | 2007-08-06 06:42:24 | [diff] [blame] | 283 | <p>Use <em>git commit</em> to store the current contents of the index in a new |
| 284 | commit along with a log message describing the changes you have made.</p> |
Junio C Hamano | b515b6a | 2007-08-08 09:21:16 | [diff] [blame] | 285 | <p>The content to be added can be specified in several ways:</p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 286 | <ol> |
| 287 | <li> |
| 288 | <p> |
Junio C Hamano | b515b6a | 2007-08-08 09:21:16 | [diff] [blame] | 289 | by 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 Hamano | bd2b4bb | 2007-08-06 06:42:24 | [diff] [blame] | 296 | by 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 Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 298 | </p> |
| 299 | </li> |
| 300 | <li> |
| 301 | <p> |
Junio C Hamano | bd2b4bb | 2007-08-06 06:42:24 | [diff] [blame] | 302 | by 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 Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 305 | </p> |
| 306 | </li> |
| 307 | <li> |
| 308 | <p> |
Junio C Hamano | bd2b4bb | 2007-08-06 06:42:24 | [diff] [blame] | 309 | by 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 Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 314 | </p> |
| 315 | </li> |
Junio C Hamano | c51fede | 2007-03-12 07:29:20 | [diff] [blame] | 316 | <li> |
| 317 | <p> |
| 318 | by 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 Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 323 | </ol> |
| 324 | <p>The <a href="git-status.html">git-status(1)</a> command can be used to obtain a |
| 325 | summary of what is included by any of the above for the next |
| 326 | commit by giving the same set of parameters you would give to |
| 327 | this command.</p> |
| 328 | <p>If you make a commit and then found a mistake immediately after |
| 329 | that, you can recover from it with <a href="git-reset.html">git-reset(1)</a>.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 330 | </div> |
| 331 | <h2>OPTIONS</h2> |
| 332 | <div class="sectionbody"> |
| 333 | <dl> |
| 334 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 335 | -a |
| 336 | </dt> |
| 337 | <dt> |
| 338 | --all |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 339 | </dt> |
| 340 | <dd> |
| 341 | <p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 342 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 345 | </p> |
| 346 | </dd> |
| 347 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 348 | -C <commit> |
| 349 | </dt> |
| 350 | <dt> |
| 351 | --reuse-message=<commit> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 352 | </dt> |
| 353 | <dd> |
| 354 | <p> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 355 | Take an existing commit object, and reuse the log message |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 356 | and the authorship information (including the timestamp) |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 357 | when creating the commit. |
| 358 | </p> |
| 359 | </dd> |
| 360 | <dt> |
| 361 | -c <commit> |
| 362 | </dt> |
| 363 | <dt> |
| 364 | --reedit-message=<commit> |
| 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 370 | </p> |
| 371 | </dd> |
| 372 | <dt> |
| 373 | -F <file> |
| 374 | </dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 375 | <dt> |
| 376 | --file=<file> |
| 377 | </dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 378 | <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 Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 385 | --author=<author> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 386 | </dt> |
| 387 | <dd> |
| 388 | <p> |
| 389 | Override the author name used in the commit. Use |
| 390 | <tt>A U Thor <author@example.com></tt> format. |
| 391 | </p> |
| 392 | </dd> |
| 393 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 394 | -m <msg> |
| 395 | </dt> |
| 396 | <dt> |
| 397 | --message=<msg> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 398 | </dt> |
| 399 | <dd> |
| 400 | <p> |
| 401 | Use the given <msg> as the commit message. |
| 402 | </p> |
| 403 | </dd> |
| 404 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 405 | -t <file> |
| 406 | </dt> |
| 407 | <dt> |
| 408 | --template=<file> |
Junio C Hamano | a3770f9 | 2007-07-25 08:53:33 | [diff] [blame] | 409 | </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 Hamano | b968dbb | 2007-07-27 07:26:40 | [diff] [blame] | 415 | 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 Hamano | a3770f9 | 2007-07-25 08:53:33 | [diff] [blame] | 417 | </p> |
| 418 | </dd> |
| 419 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 420 | -s |
| 421 | </dt> |
| 422 | <dt> |
| 423 | --signoff |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 424 | </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 Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 431 | -n |
| 432 | </dt> |
| 433 | <dt> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 434 | --no-verify |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 435 | </dt> |
| 436 | <dd> |
| 437 | <p> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 438 | This option bypasses the pre-commit and commit-msg hooks. |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 439 | See also <a href="githooks.html">githooks(5)</a>[hooks]. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 440 | </p> |
| 441 | </dd> |
| 442 | <dt> |
Junio C Hamano | 0c99970 | 2007-12-03 09:57:55 | [diff] [blame] | 443 | --allow-empty |
| 444 | </dt> |
| 445 | <dd> |
| 446 | <p> |
| 447 | Usually recording a commit that has the exact same tree as its |
Junio C Hamano | 5825687 | 2007-12-04 08:31:13 | [diff] [blame] | 448 | 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 Hamano | 0c99970 | 2007-12-03 09:57:55 | [diff] [blame] | 451 | </p> |
| 452 | </dd> |
| 453 | <dt> |
Junio C Hamano | 554da79 | 2007-12-27 03:29:58 | [diff] [blame] | 454 | --cleanup=<mode> |
| 455 | </dt> |
| 456 | <dd> |
| 457 | <p> |
| 458 | This option sets how the commit message is cleaned up. |
| 459 | The <em><mode></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 Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 469 | -e |
| 470 | </dt> |
| 471 | <dt> |
| 472 | --edit |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 473 | </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 Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 483 | --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 — if it was a merge, it will have the parents of |
| 493 | the current tip as parents — 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 Hamano | 47ea30e | 2006-04-05 23:08:03 | [diff] [blame] | 501 | $ git commit -c ORIG_HEAD |
| 502 | </tt></pre> |
Junio C Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 503 | </div></div> |
| 504 | <p>but can be used to amend a merge commit.</p> |
| 505 | </dd> |
| 506 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 507 | -i |
| 508 | </dt> |
| 509 | <dt> |
| 510 | --include |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 511 | </dt> |
| 512 | <dd> |
| 513 | <p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 514 | 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 Hamano | 6697ac5 | 2006-02-14 08:00:23 | [diff] [blame] | 518 | </p> |
| 519 | </dd> |
| 520 | <dt> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 521 | -o |
| 522 | </dt> |
| 523 | <dt> |
| 524 | --only |
Junio C Hamano | e79159d | 2008-04-12 08:23:17 | [diff] [blame] | 525 | </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 Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 540 | -u |
| 541 | </dt> |
| 542 | <dt> |
| 543 | --untracked-files |
Junio C Hamano | 1e6e006 | 2007-07-13 05:33:25 | [diff] [blame] | 544 | </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 Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 555 | -v |
| 556 | </dt> |
| 557 | <dt> |
| 558 | --verbose |
Junio C Hamano | 1e6e006 | 2007-07-13 05:33:25 | [diff] [blame] | 559 | </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 Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 569 | -q |
| 570 | </dt> |
| 571 | <dt> |
| 572 | --quiet |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 573 | </dt> |
| 574 | <dd> |
| 575 | <p> |
Junio C Hamano | f9771f6 | 2007-01-17 17:42:30 | [diff] [blame] | 576 | Suppress commit summary message. |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 577 | </p> |
| 578 | </dd> |
| 579 | <dt> |
Junio C Hamano | 1bb569e | 2006-05-05 23:14:25 | [diff] [blame] | 580 | -- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 581 | </dt> |
| 582 | <dd> |
| 583 | <p> |
| 584 | Do not interpret any more arguments as options. |
| 585 | </p> |
| 586 | </dd> |
| 587 | <dt> |
| 588 | <file>… |
| 589 | </dt> |
| 590 | <dd> |
| 591 | <p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 592 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 597 | </p> |
| 598 | </dd> |
| 599 | </dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 600 | </div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 601 | <h2>EXAMPLES</h2> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 602 | <div class="sectionbody"> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 603 | <p>When recording your own work, the contents of modified files in |
| 604 | your working tree are temporarily stored to a staging area |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 605 | called the "index" with <a href="git-add.html">git-add(1)</a>. A file can be |
| 606 | reverted back, only in the index but not in the working tree, |
| 607 | to that of the last commit with <tt>git-reset HEAD — <file></tt>, |
| 608 | which effectively reverts <tt>git-add</tt> and prevents the changes to |
| 609 | this file from participating in the next commit. After building |
| 610 | the state to be committed incrementally with these commands, |
| 611 | <tt>git commit</tt> (without any pathname parameter) is used to record what |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 612 | has been staged so far. This is the most basic form of the |
| 613 | command. An example:</p> |
| 614 | <div class="listingblock"> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 615 | <div class="content"> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 616 | <pre><tt>$ edit hello.c |
| 617 | $ git rm goodbye.c |
| 618 | $ git add hello.c |
| 619 | $ git commit</tt></pre> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 620 | </div></div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 621 | <p>Instead of staging files after each individual change, you can |
| 622 | tell <tt>git commit</tt> to notice the changes to the files whose |
| 623 | contents are tracked in |
| 624 | your working tree and do corresponding <tt>git add</tt> and <tt>git rm</tt> |
| 625 | for you. That is, this example does the same as the earlier |
| 626 | example 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, |
| 634 | notices that you have modified hello.c and removed goodbye.c, |
| 635 | and 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 |
| 637 | changes are recorded in, by giving pathnames to <tt>git commit</tt>. |
| 638 | When pathnames are given, the command makes a commit that |
| 639 | only 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>. |
| 648 | The changes staged for <tt>hello.c</tt> and <tt>hello.h</tt> are not included |
| 649 | in the resulting commit. However, their changes are not lost — |
| 650 | they are still staged and merely held back. After the above |
| 651 | sequence, 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 |
| 660 | paths are already staged to be committed for you, and paths that |
| 661 | conflicted are left in unmerged state. You would have to first |
| 662 | check which paths are conflicting with <a href="git-status.html">git-status(1)</a> |
| 663 | and after fixing them manually in your working tree, you would |
| 664 | stage 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 |
| 668 | unmerged: 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> |
| 673 | would stop mentioning the conflicted path. When you are done, |
| 674 | run <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> |
| 680 | option to save typing. One difference is that during a merge |
| 681 | resolution, you cannot use <tt>git commit</tt> with pathnames to |
| 682 | alter the order the changes are committed, because the merge |
| 683 | should be recorded as a single commit. In fact, the command |
| 684 | refuses to run when given pathnames (but see <tt>-i</tt> option).</p> |
| 685 | </div> |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 686 | <h2>DISCUSSION</h2> |
| 687 | <div class="sectionbody"> |
Junio C Hamano | 8f76dc6 | 2007-01-17 07:24:25 | [diff] [blame] | 688 | <p>Though not required, it's a good idea to begin the commit message |
| 689 | with a single short (less than 50 character) line summarizing the |
| 690 | change, followed by a blank line and then a more thorough description. |
| 691 | Tools that turn commits into email, for example, use the first line |
| 692 | on the Subject: line and the rest of the commit in the body.</p> |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 693 | <p>At the core level, git is character encoding agnostic.</p> |
| 694 | <ul> |
| 695 | <li> |
| 696 | <p> |
| 697 | The 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> |
| 707 | The 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> |
| 714 | The 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 |
| 720 | in UTF-8, both the core and git Porcelain are designed not to |
| 721 | force UTF-8 on projects. If all participants of a particular |
| 722 | project find it more convenient to use legacy encodings, git |
| 723 | does not forbid it. However, there are a few things to keep in |
| 724 | mind.</p> |
| 725 | <ol> |
| 726 | <li> |
| 727 | <p> |
| 728 | <tt>git-commit-tree</tt> (hence, <tt>git-commit</tt> which uses it) issues |
Junio C Hamano | 14b7648 | 2008-01-05 10:32:26 | [diff] [blame] | 729 | a warning if the commit log message given to it does not look |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 730 | 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 Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 732 | have i18n.commitencoding in <tt>.git/config</tt> file, like this: |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 733 | </p> |
| 734 | <div class="listingblock"> |
| 735 | <div class="content"> |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 736 | <pre><tt>[i18n] |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 737 | commitencoding = ISO-8859-1</tt></pre> |
| 738 | </div></div> |
| 739 | <p>Commit objects created with the above setting record the value |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 740 | of <tt>i18n.commitencoding</tt> in its <tt>encoding</tt> header. This is to |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 741 | help other people who look at them later. Lack of this header |
| 742 | implies 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 Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 750 | <tt>i18n.logoutputencoding</tt> in <tt>.git/config</tt> file, like this: |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 751 | </p> |
| 752 | <div class="listingblock"> |
| 753 | <div class="content"> |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 754 | <pre><tt>[i18n] |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 755 | logoutputencoding = ISO-8859-1</tt></pre> |
| 756 | </div></div> |
| 757 | <p>If you do not have this configuration variable, the value of |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 758 | <tt>i18n.commitencoding</tt> is used instead.</p> |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 759 | </li> |
| 760 | </ol> |
| 761 | <p>Note that we deliberately chose not to re-code the commit log |
| 762 | message when a commit is made to force UTF-8 at the commit |
| 763 | object level, because re-coding to UTF-8 is not necessarily a |
| 764 | reversible operation.</p> |
| 765 | </div> |
Junio C Hamano | f6002a9 | 2007-07-20 10:28:22 | [diff] [blame] | 766 | <h2>ENVIRONMENT AND CONFIGURATION VARIABLES</h2> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 767 | <div class="sectionbody"> |
Junio C Hamano | f6002a9 | 2007-07-20 10:28:22 | [diff] [blame] | 768 | <p>The editor used to edit the commit log message will be chosen from the |
| 769 | GIT_EDITOR environment variable, the core.editor configuration variable, the |
| 770 | VISUAL environment variable, or the EDITOR environment variable (in that |
| 771 | order).</p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 772 | </div> |
| 773 | <h2>HOOKS</h2> |
| 774 | <div class="sectionbody"> |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 775 | <p>This command can run <tt>commit-msg</tt>, <tt>prepare-commit-msg</tt>, <tt>pre-commit</tt>, |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [diff] [blame] | 776 | and <tt>post-commit</tt> hooks. See <a href="githooks.html">githooks(5)</a>[hooks] for more |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 777 | information.</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 Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 786 | </div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 787 | <h2>Author</h2> |
| 788 | <div class="sectionbody"> |
| 789 | <p>Written by Linus Torvalds <torvalds@osdl.org> and |
| 790 | Junio C Hamano <junkio@cox.net></p> |
| 791 | </div> |
| 792 | <h2>GIT</h2> |
| 793 | <div class="sectionbody"> |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 794 | <p>Part of the <a href="git.html">git(1)</a> suite</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 795 | </div> |
| 796 | <div id="footer"> |
| 797 | <div id="footer-text"> |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 798 | Last updated 08-Jun-2008 22:46:24 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 799 | </div> |
| 800 | </div> |
| 801 | </body> |
| 802 | </html> |