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 | c51fede | 2007-03-12 07:29:20 | [diff] [blame] | 276 | <div class="content"><em>git-commit</em> [-a | --interactive] [-s] [-v] |
| 277 | [(-c | -C) <commit> | -F <file> | -m <msg> | --amend] |
| 278 | [--no-verify] [-e] [--author <author>] |
Junio C Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 279 | [--] [[-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 | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 283 | <p>Use <em>git commit</em> when you want to record your changes into the repository |
| 284 | along with a log message describing what the commit is about. All changes |
| 285 | to be committed must be explicitly identified using one of the following |
| 286 | methods:</p> |
| 287 | <ol> |
| 288 | <li> |
| 289 | <p> |
| 290 | by 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> |
| 297 | by 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> |
| 303 | by 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> |
| 310 | by 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 Hamano | ffaf0e2 | 2007-01-13 22:18:22 | [diff] [blame] | 312 | before, and to automatically "rm" files that have been |
| 313 | removed from the working tree, and perform the 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> |
| 335 | -a|--all |
| 336 | </dt> |
| 337 | <dd> |
| 338 | <p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 339 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 342 | </p> |
| 343 | </dd> |
| 344 | <dt> |
| 345 | -c or -C <commit> |
| 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 <file> |
| 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 Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 366 | --author <author> |
| 367 | </dt> |
| 368 | <dd> |
| 369 | <p> |
| 370 | Override the author name used in the commit. Use |
| 371 | <tt>A U Thor <author@example.com></tt> format. |
| 372 | </p> |
| 373 | </dd> |
| 374 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 375 | -m <msg> |
| 376 | </dt> |
| 377 | <dd> |
| 378 | <p> |
| 379 | Use the given <msg> 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 Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 391 | --no-verify |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 392 | </dt> |
| 393 | <dd> |
| 394 | <p> |
Junio C Hamano | 24351a8 | 2007-01-13 08:09:17 | [diff] [blame] | 395 | This option bypasses the pre-commit hook. |
| 396 | See also <a href="hooks.html">hooks</a>. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 397 | </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 Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 411 | --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 — if it was a merge, it will have the parents of |
| 421 | the current tip as parents — 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 Hamano | 47ea30e | 2006-04-05 23:08:03 | [diff] [blame] | 429 | $ git commit -c ORIG_HEAD |
| 430 | </tt></pre> |
Junio C Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 431 | </div></div> |
| 432 | <p>but can be used to amend a merge commit.</p> |
| 433 | </dd> |
| 434 | <dt> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 435 | -i|--include |
| 436 | </dt> |
| 437 | <dd> |
| 438 | <p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 439 | 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 Hamano | 6697ac5 | 2006-02-14 08:00:23 | [diff] [blame] | 443 | </p> |
| 444 | </dd> |
| 445 | <dt> |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 446 | -q|--quiet |
| 447 | </dt> |
| 448 | <dd> |
| 449 | <p> |
Junio C Hamano | f9771f6 | 2007-01-17 17:42:30 | [diff] [blame] | 450 | Suppress commit summary message. |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 451 | </p> |
| 452 | </dd> |
| 453 | <dt> |
Junio C Hamano | 1bb569e | 2006-05-05 23:14:25 | [diff] [blame] | 454 | -- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 455 | </dt> |
| 456 | <dd> |
| 457 | <p> |
| 458 | Do not interpret any more arguments as options. |
| 459 | </p> |
| 460 | </dd> |
| 461 | <dt> |
| 462 | <file>… |
| 463 | </dt> |
| 464 | <dd> |
| 465 | <p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 466 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 471 | </p> |
| 472 | </dd> |
| 473 | </dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 474 | </div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 475 | <h2>EXAMPLES</h2> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 476 | <div class="sectionbody"> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 477 | <p>When recording your own work, the contents of modified files in |
| 478 | your working tree are temporarily stored to a staging area |
| 479 | called the "index" with <a href="git-add.html">git-add(1)</a>. Removal |
| 480 | of a file is staged with <a href="git-rm.html">git-rm(1)</a>. After building the |
| 481 | state to be committed incrementally with these commands, <tt>git |
| 482 | commit</tt> (without any pathname parameter) is used to record what |
| 483 | has been staged so far. This is the most basic form of the |
| 484 | command. An example:</p> |
| 485 | <div class="listingblock"> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 486 | <div class="content"> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 487 | <pre><tt>$ edit hello.c |
| 488 | $ git rm goodbye.c |
| 489 | $ git add hello.c |
| 490 | $ git commit</tt></pre> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 491 | </div></div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 492 | <p>Instead of staging files after each individual change, you can |
| 493 | tell <tt>git commit</tt> to notice the changes to the files whose |
| 494 | contents are tracked in |
| 495 | your working tree and do corresponding <tt>git add</tt> and <tt>git rm</tt> |
| 496 | for you. That is, this example does the same as the earlier |
| 497 | example 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, |
| 505 | notices that you have modified hello.c and removed goodbye.c, |
| 506 | and 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 |
| 508 | changes are recorded in, by giving pathnames to <tt>git commit</tt>. |
| 509 | When pathnames are given, the command makes a commit that |
| 510 | only 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>. |
| 519 | The changes staged for <tt>hello.c</tt> and <tt>hello.h</tt> are not included |
| 520 | in the resulting commit. However, their changes are not lost — |
| 521 | they are still staged and merely held back. After the above |
| 522 | sequence, 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 |
| 531 | paths are already staged to be committed for you, and paths that |
| 532 | conflicted are left in unmerged state. You would have to first |
| 533 | check which paths are conflicting with <a href="git-status.html">git-status(1)</a> |
| 534 | and after fixing them manually in your working tree, you would |
| 535 | stage 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 |
| 539 | unmerged: 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> |
| 544 | would stop mentioning the conflicted path. When you are done, |
| 545 | run <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> |
| 551 | option to save typing. One difference is that during a merge |
| 552 | resolution, you cannot use <tt>git commit</tt> with pathnames to |
| 553 | alter the order the changes are committed, because the merge |
| 554 | should be recorded as a single commit. In fact, the command |
| 555 | refuses to run when given pathnames (but see <tt>-i</tt> option).</p> |
| 556 | </div> |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 557 | <h2>DISCUSSION</h2> |
| 558 | <div class="sectionbody"> |
Junio C Hamano | 8f76dc6 | 2007-01-17 07:24:25 | [diff] [blame] | 559 | <p>Though not required, it's a good idea to begin the commit message |
| 560 | with a single short (less than 50 character) line summarizing the |
| 561 | change, followed by a blank line and then a more thorough description. |
| 562 | Tools that turn commits into email, for example, use the first line |
| 563 | 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] | 564 | <p>At the core level, git is character encoding agnostic.</p> |
| 565 | <ul> |
| 566 | <li> |
| 567 | <p> |
| 568 | The 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> |
| 578 | The 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> |
| 585 | The 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 |
| 591 | in UTF-8, both the core and git Porcelain are designed not to |
| 592 | force UTF-8 on projects. If all participants of a particular |
| 593 | project find it more convenient to use legacy encodings, git |
| 594 | does not forbid it. However, there are a few things to keep in |
| 595 | mind.</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 Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 603 | have i18n.commitencoding in <tt>.git/config</tt> file, like this: |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 604 | </p> |
| 605 | <div class="listingblock"> |
| 606 | <div class="content"> |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 607 | <pre><tt>[i18n] |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 608 | commitencoding = ISO-8859-1</tt></pre> |
| 609 | </div></div> |
| 610 | <p>Commit objects created with the above setting record the value |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 611 | 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] | 612 | help other people who look at them later. Lack of this header |
| 613 | implies 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 Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 621 | <tt>i18n.logoutputencoding</tt> in <tt>.git/config</tt> file, like this: |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 622 | </p> |
| 623 | <div class="listingblock"> |
| 624 | <div class="content"> |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 625 | <pre><tt>[i18n] |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 626 | logoutputencoding = ISO-8859-1</tt></pre> |
| 627 | </div></div> |
| 628 | <p>If you do not have this configuration variable, the value of |
Junio C Hamano | 35bb3f6 | 2007-02-19 05:35:53 | [diff] [blame] | 629 | <tt>i18n.commitencoding</tt> is used instead.</p> |
Junio C Hamano | 775a0f4 | 2006-12-31 01:19:14 | [diff] [blame] | 630 | </li> |
| 631 | </ol> |
| 632 | <p>Note that we deliberately chose not to re-code the commit log |
| 633 | message when a commit is made to force UTF-8 at the commit |
| 634 | object level, because re-coding to UTF-8 is not necessarily a |
| 635 | reversible operation.</p> |
| 636 | </div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 637 | <h2>ENVIRONMENT VARIABLES</h2> |
| 638 | <div class="sectionbody"> |
| 639 | <p>The command specified by either the VISUAL or EDITOR environment |
| 640 | variables 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 |
| 646 | information.</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 Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 655 | </div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 656 | <h2>Author</h2> |
| 657 | <div class="sectionbody"> |
| 658 | <p>Written by Linus Torvalds <torvalds@osdl.org> and |
| 659 | Junio C Hamano <junkio@cox.net></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 Hamano | 20f64da | 2007-04-04 18:38:30 | [diff] [blame] | 667 | Last updated 04-Apr-2007 18:33:34 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 668 | </div> |
| 669 | </div> |
| 670 | </body> |
| 671 | </html> |