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">
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">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.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
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
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
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
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
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 gitcli(
7) Manual Page
409 <div class=
"sectionbody">
411 git command line interface and conventions
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"paragraph"><p>gitcli
</p></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>
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>
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.
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
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>
463 it
’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>.
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).
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.
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.
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>
506 gives a pretty printed usage of the command.
508 <div class=
"listingblock">
509 <div class=
"content">
510 <pre><tt>$ git describe -h
511 usage: git describe [options]
<committish
>*
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 [
<n
>] use
<n
> digits to display SHA-
1s
518 --candidates
<n
> consider
<n
> most recent tags (default:
10)
</tt></pre>
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.
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
549 $ git foo -o Arg
</tt></pre>
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>
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> — these two options mean very
567 different things.
</p></div>
568 <div class=
"ulist"><ul>
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
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
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
597 <div class=
"paragraph"><p>See also
<a href=
"http://marc.info/?l=git&m=116563135620359">http://marc.info/?l=git
&m=
116563135620359</a> and
598 <a href=
"http://marc.info/?l=git&m=119150393620273">http://marc.info/?l=git
&m=
119150393620273</a> for further
599 information.
</p></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>
606 <div id=
"footer-text">
607 Last updated
2011-
03-
15 23:
30:
15 UTC