Autogenerated HTML docs for v1.7.5-185-g0b9dee
[git/jnareb-git.git] / gitcli.html
bloba25f73361e34bcb5b5e15e1fade6618dd28eb033
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" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>gitcli(7)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 gitcli(7) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>gitcli -
411 git command line interface and conventions
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="paragraph"><p>gitcli</p></div>
418 </div>
419 <h2 id="_description">DESCRIPTION</h2>
420 <div class="sectionbody">
421 <div class="paragraph"><p>This manual describes the convention used throughout git CLI.</p></div>
422 <div class="paragraph"><p>Many commands take revisions (most often "commits", but sometimes
423 "tree-ish", depending on the context and command) and paths as their
424 arguments. Here are the rules:</p></div>
425 <div class="ulist"><ul>
426 <li>
428 Revisions come first and then paths.
429 E.g. in <tt>git diff v1.0 v2.0 arch/x86 include/asm-x86</tt>,
430 <tt>v1.0</tt> and <tt>v2.0</tt> are revisions and <tt>arch/x86</tt> and <tt>include/asm-x86</tt>
431 are paths.
432 </p>
433 </li>
434 <li>
436 When an argument can be misunderstood as either a revision or a path,
437 they can be disambiguated by placing <tt>--</tt> between them.
438 E.g. <tt>git diff -- HEAD</tt> is, "I have a file called HEAD in my work
439 tree. Please show changes between the version I staged in the index
440 and what I have in the work tree for that file". not "show difference
441 between the HEAD commit and the work tree as a whole". You can say
442 <tt>git diff HEAD --</tt> to ask for the latter.
443 </p>
444 </li>
445 <li>
447 Without disambiguating <tt>--</tt>, git makes a reasonable guess, but errors
448 out and asking you to disambiguate when ambiguous. E.g. if you have a
449 file called HEAD in your work tree, <tt>git diff HEAD</tt> is ambiguous, and
450 you have to say either <tt>git diff HEAD --</tt> or <tt>git diff -- HEAD</tt> to
451 disambiguate.
452 </p>
453 </li>
454 </ul></div>
455 <div class="paragraph"><p>When writing a script that is expected to handle random user-input, it is
456 a good practice to make it explicit which arguments are which by placing
457 disambiguating <tt>--</tt> at appropriate places.</p></div>
458 <div class="paragraph"><p>Here are the rules regarding the "flags" that you should follow when you are
459 scripting git:</p></div>
460 <div class="ulist"><ul>
461 <li>
463 it&#8217;s preferred to use the non dashed form of git commands, which means that
464 you should prefer <tt>git foo</tt> to <tt>git-foo</tt>.
465 </p>
466 </li>
467 <li>
469 splitting short options to separate words (prefer <tt>git foo -a -b</tt>
470 to <tt>git foo -ab</tt>, the latter may not even work).
471 </p>
472 </li>
473 <li>
475 when a command line option takes an argument, use the <em>sticked</em> form. In
476 other words, write <tt>git foo -oArg</tt> instead of <tt>git foo -o Arg</tt> for short
477 options, and <tt>git foo --long-opt=Arg</tt> instead of <tt>git foo --long-opt Arg</tt>
478 for long options. An option that takes optional option-argument must be
479 written in the <em>sticked</em> form.
480 </p>
481 </li>
482 <li>
484 when you give a revision parameter to a command, make sure the parameter is
485 not ambiguous with a name of a file in the work tree. E.g. do not write
486 <tt>git log -1 HEAD</tt> but write <tt>git log -1 HEAD --</tt>; the former will not work
487 if you happen to have a file called <tt>HEAD</tt> in the work tree.
488 </p>
489 </li>
490 </ul></div>
491 </div>
492 <h2 id="_enhanced_option_parser">ENHANCED OPTION PARSER</h2>
493 <div class="sectionbody">
494 <div class="paragraph"><p>From the git 1.5.4 series and further, many git commands (not all of them at the
495 time of the writing though) come with an enhanced option parser.</p></div>
496 <div class="paragraph"><p>Here is an exhaustive list of the facilities provided by this option parser.</p></div>
497 <h3 id="_magic_options">Magic Options</h3><div style="clear:left"></div>
498 <div class="paragraph"><p>Commands which have the enhanced option parser activated all understand a
499 couple of magic command line options:</p></div>
500 <div class="dlist"><dl>
501 <dt class="hdlist1">
503 </dt>
504 <dd>
506 gives a pretty printed usage of the command.
507 </p>
508 <div class="listingblock">
509 <div class="content">
510 <pre><tt>$ git describe -h
511 usage: git describe [options] &lt;committish&gt;*
513 --contains find the tag that comes after the commit
514 --debug debug search strategy on stderr
515 --all use any ref in .git/refs
516 --tags use any tag in .git/refs/tags
517 --abbrev [&lt;n&gt;] use &lt;n&gt; digits to display SHA-1s
518 --candidates &lt;n&gt; consider &lt;n&gt; most recent tags (default: 10)</tt></pre>
519 </div></div>
520 </dd>
521 <dt class="hdlist1">
522 --help-all
523 </dt>
524 <dd>
526 Some git commands take options that are only used for plumbing or that
527 are deprecated, and such options are hidden from the default usage. This
528 option gives the full list of options.
529 </p>
530 </dd>
531 </dl></div>
532 <h3 id="_negating_options">Negating options</h3><div style="clear:left"></div>
533 <div class="paragraph"><p>Options with long option names can be negated by prefixing <tt>--no-</tt>. For
534 example, <tt>git branch</tt> has the option <tt>--track</tt> which is <em>on</em> by default. You
535 can use <tt>--no-track</tt> to override that behaviour. The same goes for <tt>--color</tt>
536 and <tt>--no-color</tt>.</p></div>
537 <h3 id="_aggregating_short_options">Aggregating short options</h3><div style="clear:left"></div>
538 <div class="paragraph"><p>Commands that support the enhanced option parser allow you to aggregate short
539 options. This means that you can for example use <tt>git rm -rf</tt> or
540 <tt>git clean -fdx</tt>.</p></div>
541 <h3 id="_separating_argument_from_the_option">Separating argument from the option</h3><div style="clear:left"></div>
542 <div class="paragraph"><p>You can write the mandatory option parameter to an option as a separate
543 word on the command line. That means that all the following uses work:</p></div>
544 <div class="listingblock">
545 <div class="content">
546 <pre><tt>$ git foo --long-opt=Arg
547 $ git foo --long-opt Arg
548 $ git foo -oArg
549 $ git foo -o Arg</tt></pre>
550 </div></div>
551 <div class="paragraph"><p>However, this is <strong>NOT</strong> allowed for switches with an optional value, where the
552 <em>sticked</em> form must be used:</p></div>
553 <div class="listingblock">
554 <div class="content">
555 <pre><tt>$ git describe --abbrev HEAD # correct
556 $ git describe --abbrev=10 HEAD # correct
557 $ git describe --abbrev 10 HEAD # NOT WHAT YOU MEANT</tt></pre>
558 </div></div>
559 </div>
560 <h2 id="_notes_on_frequently_confused_options">NOTES ON FREQUENTLY CONFUSED OPTIONS</h2>
561 <div class="sectionbody">
562 <div class="paragraph"><p>Many commands that can work on files in the working tree
563 and/or in the index can take <tt>--cached</tt> and/or <tt>--index</tt>
564 options. Sometimes people incorrectly think that, because
565 the index was originally called cache, these two are
566 synonyms. They are <strong>not</strong>&#8201;&#8212;&#8201;these two options mean very
567 different things.</p></div>
568 <div class="ulist"><ul>
569 <li>
571 The <tt>--cached</tt> option is used to ask a command that
572 usually works on files in the working tree to <strong>only</strong> work
573 with the index. For example, <tt>git grep</tt>, when used
574 without a commit to specify from which commit to look for
575 strings in, usually works on files in the working tree,
576 but with the <tt>--cached</tt> option, it looks for strings in
577 the index.
578 </p>
579 </li>
580 <li>
582 The <tt>--index</tt> option is used to ask a command that
583 usually works on files in the working tree to <strong>also</strong>
584 affect the index. For example, <tt>git stash apply</tt> usually
585 merges changes recorded in a stash to the working tree,
586 but with the <tt>--index</tt> option, it also merges changes to
587 the index as well.
588 </p>
589 </li>
590 </ul></div>
591 <div class="paragraph"><p><tt>git apply</tt> command can be used with <tt>--cached</tt> and
592 <tt>--index</tt> (but not at the same time). Usually the command
593 only affects the files in the working tree, but with
594 <tt>--index</tt>, it patches both the files and their index
595 entries, and with <tt>--cached</tt>, it modifies only the index
596 entries.</p></div>
597 <div class="paragraph"><p>See also <a href="http://marc.info/?l=git&amp;m=116563135620359">http://marc.info/?l=git&amp;m=116563135620359</a> and
598 <a href="http://marc.info/?l=git&amp;m=119150393620273">http://marc.info/?l=git&amp;m=119150393620273</a> for further
599 information.</p></div>
600 </div>
601 <h2 id="_git">GIT</h2>
602 <div class="sectionbody">
603 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
604 </div>
605 <div id="footer">
606 <div id="footer-text">
607 Last updated 2011-03-15 23:30:15 UTC
608 </div>
609 </div>
610 </body>
611 </html>