CINXE.COM
Git - gitcli Documentation
<!DOCTYPE html> <html lang="en"> <head> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - gitcli Documentation</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about">About</a> <ul> </ul> </li> <li> <a href="/doc" class="active">Documentation</a> <ul class="expanded"> <li> <a href="/docs" class="active">Reference</a> </li> <li> <a href="/book">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> </nav> </aside> <div id="content"> <div id='reference-version'> <a class="dropdown-trigger" id="reference-languages-trigger" data-panel-id="l10n-versions-dropdown" href="#"> English ▾</a> <div class='dropdown-panel right' id='l10n-versions-dropdown'> <header>Localized versions of <strong>gitcli</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/gitcli"><span class="version">English</span> </a> </li> </ol> <footer> Want to read in your language or fix typos?<br/> <a href="https://github.com/jnavila/git-manpages-l10n">You can help translate this page</a>. </footer> </div> <a class="dropdown-trigger" id="reference-topics-trigger" data-panel-id="topics-dropdown" href="#">Topics ▾</a> <div class='dropdown-panel right' id='topics-dropdown'> <div class='three-column'> <div class='column-left'> <h3 class='setup'>Setup and Config</h3> <ul class='unstyled'> <li> <a href="/docs/git"> git </a> </li> <li> <a href="/docs/git-config"> config </a> </li> <li> <a href="/docs/git-help"> help </a> </li> <li> <a href="/docs/git-bugreport"> bugreport </a> </li> <li> <a href="/doc/credential-helpers"> Credential helpers </a> </li> </ul> <h3 class='projects'>Getting and Creating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-init"> init </a> </li> <li> <a href="/docs/git-clone"> clone </a> </li> </ul> <h3 class='snapshotting'>Basic Snapshotting</h3> <ul class='unstyled'> <li> <a href="/docs/git-add"> add </a> </li> <li> <a href="/docs/git-status"> status </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-commit"> commit </a> </li> <li> <a href="/docs/git-notes"> notes </a> </li> <li> <a href="/docs/git-restore"> restore </a> </li> <li> <a href="/docs/git-reset"> reset </a> </li> <li> <a href="/docs/git-rm"> rm </a> </li> <li> <a href="/docs/git-mv"> mv </a> </li> </ul> <h3 class='branching'>Branching and Merging</h3> <ul class='unstyled'> <li> <a href="/docs/git-branch"> branch </a> </li> <li> <a href="/docs/git-checkout"> checkout </a> </li> <li> <a href="/docs/git-switch"> switch </a> </li> <li> <a href="/docs/git-merge"> merge </a> </li> <li> <a href="/docs/git-mergetool"> mergetool </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-stash"> stash </a> </li> <li> <a href="/docs/git-tag"> tag </a> </li> <li> <a href="/docs/git-worktree"> worktree </a> </li> </ul> <h3 class='sharing'>Sharing and Updating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-fetch"> fetch </a> </li> <li> <a href="/docs/git-pull"> pull </a> </li> <li> <a href="/docs/git-push"> push </a> </li> <li> <a href="/docs/git-remote"> remote </a> </li> <li> <a href="/docs/git-submodule"> submodule </a> </li> </ul> </div> <div class='column-middle'> <h3 class='inspection'>Inspection and Comparison</h3> <ul class='unstyled'> <li> <a href="/docs/git-show"> show </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-difftool"> difftool </a> </li> <li> <a href="/docs/git-range-diff"> range-diff </a> </li> <li> <a href="/docs/git-shortlog"> shortlog </a> </li> <li> <a href="/docs/git-describe"> describe </a> </li> </ul> <h3 class='patching'>Patching</h3> <ul class='unstyled'> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-cherry-pick"> cherry-pick </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-rebase"> rebase </a> </li> <li> <a href="/docs/git-revert"> revert </a> </li> </ul> <h3 class='debugging'>Debugging</h3> <ul class='unstyled'> <li> <a href="/docs/git-bisect"> bisect </a> </li> <li> <a href="/docs/git-blame"> blame </a> </li> <li> <a href="/docs/git-grep"> grep </a> </li> </ul> <h3 class='email'>Email</h3> <ul class='unstyled'> <li> <a href="/docs/git-am"> am </a> </li> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-format-patch"> format-patch </a> </li> <li> <a href="/docs/git-send-email"> send-email </a> </li> <li> <a href="/docs/git-request-pull"> request-pull </a> </li> </ul> <h3 class='external'>External Systems</h3> <ul class='unstyled'> <li> <a href="/docs/git-svn"> svn </a> </li> <li> <a href="/docs/git-fast-import"> fast-import </a> </li> </ul> <h3 class='server-admin'>Server Admin</h3> <ul class='unstyled'> <li> <a href="/docs/git-daemon"> daemon </a> </li> <li> <a href="/docs/git-update-server-info"> update-server-info </a> </li> </ul> </div> <div class='column-right'> <h3 class='guides'>Guides</h3> <ul class='unstyled'> <li> <a href="/docs/gitattributes"> gitattributes </a> </li> <li> <a href="/docs/gitcli"> Command-line interface conventions </a> </li> <li> <a href="/docs/giteveryday"> Everyday Git </a> </li> <li> <a href="/docs/gitfaq"> Frequently Asked Questions (FAQ) </a> </li> <li> <a href="/docs/gitglossary"> Glossary </a> </li> <li> <a href="/docs/githooks"> Hooks </a> </li> <li> <a href="/docs/gitignore"> gitignore </a> </li> <li> <a href="/docs/gitmodules"> gitmodules </a> </li> <li> <a href="/docs/gitrevisions"> Revisions </a> </li> <li> <a href="/docs/gitsubmodules"> Submodules </a> </li> <li> <a href="/docs/gittutorial"> Tutorial </a> </li> <li> <a href="/docs/gitworkflows"> Workflows </a> </li> <li> <a href="/docs/git#_guides"> All guides... </a> </li> </ul> <h3 class='admin'>Administration</h3> <ul class='unstyled'> <li> <a href="/docs/git-clean"> clean </a> </li> <li> <a href="/docs/git-gc"> gc </a> </li> <li> <a href="/docs/git-fsck"> fsck </a> </li> <li> <a href="/docs/git-reflog"> reflog </a> </li> <li> <a href="/docs/git-filter-branch"> filter-branch </a> </li> <li> <a href="/docs/git-instaweb"> instaweb </a> </li> <li> <a href="/docs/git-archive"> archive </a> </li> <li> <a href="/docs/git-bundle"> bundle </a> </li> </ul> <h3 class='plumbing'>Plumbing Commands</h3> <ul class='unstyled'> <li> <a href="/docs/git-cat-file"> cat-file </a> </li> <li> <a href="/docs/git-check-ignore"> check-ignore </a> </li> <li> <a href="/docs/git-checkout-index"> checkout-index </a> </li> <li> <a href="/docs/git-commit-tree"> commit-tree </a> </li> <li> <a href="/docs/git-count-objects"> count-objects </a> </li> <li> <a href="/docs/git-diff-index"> diff-index </a> </li> <li> <a href="/docs/git-for-each-ref"> for-each-ref </a> </li> <li> <a href="/docs/git-hash-object"> hash-object </a> </li> <li> <a href="/docs/git-ls-files"> ls-files </a> </li> <li> <a href="/docs/git-ls-tree"> ls-tree </a> </li> <li> <a href="/docs/git-merge-base"> merge-base </a> </li> <li> <a href="/docs/git-read-tree"> read-tree </a> </li> <li> <a href="/docs/git-rev-list"> rev-list </a> </li> <li> <a href="/docs/git-rev-parse"> rev-parse </a> </li> <li> <a href="/docs/git-show-ref"> show-ref </a> </li> <li> <a href="/docs/git-symbolic-ref"> symbolic-ref </a> </li> <li> <a href="/docs/git-update-index"> update-index </a> </li> <li> <a href="/docs/git-update-ref"> update-ref </a> </li> <li> <a href="/docs/git-verify-pack"> verify-pack </a> </li> <li> <a href="/docs/git-write-tree"> write-tree </a> </li> </ul> </div> </div> </div> <a class="dropdown-trigger" id="reference-versions-trigger" data-panel-id="previous-versions-dropdown" href="#"> Latest version ▾ </a> <span class="light d-flex">gitcli last updated in 2.45.0</span> <div class='dropdown-panel left' id='previous-versions-dropdown'> <header>Changes in the <strong>gitcli</strong> manual</header> <ol class='reference-previous-versions'> <li class="no-change"><span>2.45.1 → 2.47.0 no changes</span></li> <li class="no-change"><span>2.45.0 no changes</span></li> <li class="no-change"><span>2.43.1 → 2.44.2 no changes</span></li> <li> <a href="/docs/gitcli/2.43.0"><span class="version">2.43.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">11/20/23</em> </a> </li> <li class="no-change"><span>2.36.1 → 2.42.3 no changes</span></li> <li> <a href="/docs/gitcli/2.36.0"><span class="version">2.36.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">04/18/22</em> </a> </li> <li class="no-change"><span>2.25.3 → 2.35.8 no changes</span></li> <li> <a href="/docs/gitcli/2.25.2"><span class="version">2.25.2</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">03/17/20</em> </a> </li> <li class="no-change"><span>2.25.1 no changes</span></li> <li> <a href="/docs/gitcli/2.25.0"><span class="version">2.25.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">01/13/20</em> </a> </li> <li class="no-change"><span>2.24.1 → 2.24.4 no changes</span></li> <li> <a href="/docs/gitcli/2.24.0"><span class="version">2.24.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">11/04/19</em> </a> </li> <li class="no-change"><span>2.23.1 → 2.23.4 no changes</span></li> <li> <a href="/docs/gitcli/2.23.0"><span class="version">2.23.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">08/16/19</em> </a> </li> <li class="no-change"><span>2.18.1 → 2.22.5 no changes</span></li> <li> <a href="/docs/gitcli/2.18.0"><span class="version">2.18.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">06/21/18</em> </a> </li> <li class="no-change"><span>2.15.4 → 2.17.6 no changes</span></li> <li> <a href="/docs/gitcli/2.14.6"><span class="version">2.14.6</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/06/19</em> </a> </li> <li class="no-change"><span>2.2.3 → 2.13.7 no changes</span></li> <li> <a href="/docs/gitcli/2.1.4"><span class="version">2.1.4</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/17/14</em> </a> </li> <li> <a href="/docs/gitcli/2.0.5"><span class="version">2.0.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/17/14</em> </a> </li> <li> </li> </ol> <footer> <p>Check your version of git by running</p> <code class="command">git --version</code> </footer> </div> </div> <div id="main" data-pagefind-filter="category:reference" data-pagefind-meta="category:Reference" data-pagefind-weight="0.05" data-pagefind-body> <div class="sect1"> <h2 id="_name"><a class="anchor" href="#_name"></a>NAME</h2> <div class="sectionbody"> <div class="paragraph"> <p>gitcli - Git command-line interface and conventions</p> </div> </div> </div> <div class="sect1"> <h2 id="_synopsis"><a class="anchor" href="#_synopsis"></a>SYNOPSIS</h2> <div class="sectionbody"> <div class="paragraph"> <p>gitcli</p> </div> </div> </div> <div class="sect1"> <h2 id="_description"><a class="anchor" href="#_description"></a>DESCRIPTION</h2> <div class="sectionbody"> <div class="paragraph"> <p>This manual describes the convention used throughout Git CLI.</p> </div> <div class="paragraph"> <p>Many commands take revisions (most often "commits", but sometimes "tree-ish", depending on the context and command) and paths as their arguments. Here are the rules:</p> </div> <div class="ulist"> <ul> <li> <p>Options come first and then args. A subcommand may take dashed options (which may take their own arguments, e.g. "--max-parents 2") and arguments. You SHOULD give dashed options first and then arguments. Some commands may accept dashed options after you have already given non-option arguments (which may make the command ambiguous), but you should not rely on it (because eventually we may find a way to fix these ambiguities by enforcing the "options then args" rule).</p> </li> <li> <p>Revisions come first and then paths. E.g. in <code>git diff v1.0 v2.0 arch/x86 include/asm-x86</code>, <code>v1.0</code> and <code>v2.0</code> are revisions and <code>arch/x86</code> and <code>include/asm-x86</code> are paths.</p> </li> <li> <p>When an argument can be misunderstood as either a revision or a path, they can be disambiguated by placing <code>--</code> between them. E.g. <code>git diff -- HEAD</code> is, "I have a file called HEAD in my work tree. Please show changes between the version I staged in the index and what I have in the work tree for that file", not "show the difference between the HEAD commit and the work tree as a whole". You can say <code>git diff HEAD --</code> to ask for the latter.</p> </li> <li> <p>Without disambiguating <code>--</code>, Git makes a reasonable guess, but errors out and asks you to disambiguate when ambiguous. E.g. if you have a file called HEAD in your work tree, <code>git diff HEAD</code> is ambiguous, and you have to say either <code>git diff HEAD --</code> or <code>git diff -- HEAD</code> to disambiguate.</p> </li> <li> <p>Because <code>--</code> disambiguates revisions and paths in some commands, it cannot be used for those commands to separate options and revisions. You can use <code>--end-of-options</code> for this (it also works for commands that do not distinguish between revisions in paths, in which case it is simply an alias for <code>--</code>).</p> <div class="paragraph"> <p>When writing a script that is expected to handle random user-input, it is a good practice to make it explicit which arguments are which by placing disambiguating <code>--</code> at appropriate places.</p> </div> </li> <li> <p>Many commands allow wildcards in paths, but you need to protect them from getting globbed by the shell. These two mean different things:</p> <div class="listingblock"> <div class="content"> <pre>$ git restore *.c $ git restore \*.c</pre> </div> </div> <div class="paragraph"> <p>The former lets your shell expand the fileglob, and you are asking the dot-C files in your working tree to be overwritten with the version in the index. The latter passes the <code>*.c</code> to Git, and you are asking the paths in the index that match the pattern to be checked out to your working tree. After running <code>git add hello.c; rm hello.c</code>, you will <em>not</em> see <code>hello.c</code> in your working tree with the former, but with the latter you will.</p> </div> </li> <li> <p>Just as the filesystem <em>.</em> (period) refers to the current directory, using a <em>.</em> as a repository name in Git (a dot-repository) is a relative path and means your current repository.</p> </li> </ul> </div> <div class="paragraph"> <p>Here are the rules regarding the "flags" that you should follow when you are scripting Git:</p> </div> <div class="ulist"> <ul> <li> <p>Splitting short options to separate words (prefer <code>git foo -a -b</code> to <code>git foo -ab</code>, the latter may not even work).</p> </li> <li> <p>When a command-line option takes an argument, use the <em>stuck</em> form. In other words, write <code>git foo -oArg</code> instead of <code>git foo -o Arg</code> for short options, and <code>git foo --long-opt=Arg</code> instead of <code>git foo --long-opt Arg</code> for long options. An option that takes optional option-argument must be written in the <em>stuck</em> form.</p> </li> <li> <p>When you give a revision parameter to a command, make sure the parameter is not ambiguous with a name of a file in the work tree. E.g. do not write <code>git log -1 HEAD</code> but write <code>git log -1 HEAD --</code>; the former will not work if you happen to have a file called <code>HEAD</code> in the work tree.</p> </li> <li> <p>Many commands allow a long option <code>--option</code> to be abbreviated only to their unique prefix (e.g. if there is no other option whose name begins with <code>opt</code>, you may be able to spell <code>--opt</code> to invoke the <code>--option</code> flag), but you should fully spell them out when writing your scripts; later versions of Git may introduce a new option whose name shares the same prefix, e.g. <code>--optimize</code>, to make a short prefix that used to be unique no longer unique.</p> </li> </ul> </div> </div> </div> <div class="sect1"> <h2 id="_enhanced_option_parser"><a class="anchor" href="#_enhanced_option_parser"></a>ENHANCED OPTION PARSER</h2> <div class="sectionbody"> <div class="paragraph"> <p>From the Git 1.5.4 series and further, many Git commands (not all of them at the time of the writing though) come with an enhanced option parser.</p> </div> <div class="paragraph"> <p>Here is a list of the facilities provided by this option parser.</p> </div> <div class="sect2"> <h3 id="_magic_options"><a class="anchor" href="#_magic_options"></a>Magic Options</h3> <div class="paragraph"> <p>Commands which have the enhanced option parser activated all understand a couple of magic command-line options:</p> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitcli.txt--h"> <a class="anchor" href="#Documentation/gitcli.txt--h"></a>-h </dt> <dd> <p>gives a pretty printed usage of the command.</p> <div class="listingblock"> <div class="content"> <pre>$ git describe -h usage: git describe [<options>] <commit-ish>* or: git describe [<options>] --dirty --contains find the tag that comes after the commit --debug debug search strategy on stderr --all use any ref --tags use any tag, even unannotated --long always use long format --abbrev[=<n>] use <n> digits to display SHA-1s</pre> </div> </div> <div class="paragraph"> <p>Note that some subcommand (e.g. <code>git grep</code>) may behave differently when there are things on the command line other than <code>-h</code>, but <code>git subcmd -h</code> without anything else on the command line is meant to consistently give the usage.</p> </div> </dd> <dt class="hdlist1" id="Documentation/gitcli.txt---help-all"> <a class="anchor" href="#Documentation/gitcli.txt---help-all"></a>--help-all </dt> <dd> <p>Some Git commands take options that are only used for plumbing or that are deprecated, and such options are hidden from the default usage. This option gives the full list of options.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_negating_options"><a class="anchor" href="#_negating_options"></a>Negating options</h3> <div class="paragraph"> <p>Options with long option names can be negated by prefixing <code>--no-</code>. For example, <code>git branch</code> has the option <code>--track</code> which is <em>on</em> by default. You can use <code>--no-track</code> to override that behaviour. The same goes for <code>--color</code> and <code>--no-color</code>.</p> </div> </div> <div class="sect2"> <h3 id="_aggregating_short_options"><a class="anchor" href="#_aggregating_short_options"></a>Aggregating short options</h3> <div class="paragraph"> <p>Commands that support the enhanced option parser allow you to aggregate short options. This means that you can for example use <code>git rm -rf</code> or <code>git clean -fdx</code>.</p> </div> </div> <div class="sect2"> <h3 id="_abbreviating_long_options"><a class="anchor" href="#_abbreviating_long_options"></a>Abbreviating long options</h3> <div class="paragraph"> <p>Commands that support the enhanced option parser accepts unique prefix of a long option as if it is fully spelled out, but use this with a caution. For example, <code>git commit --amen</code> behaves as if you typed <code>git commit --amend</code>, but that is true only until a later version of Git introduces another option that shares the same prefix, e.g. <code>git commit --amenity</code> option.</p> </div> </div> <div class="sect2"> <h3 id="_separating_argument_from_the_option"><a class="anchor" href="#_separating_argument_from_the_option"></a>Separating argument from the option</h3> <div class="paragraph"> <p>You can write the mandatory option parameter to an option as a separate word on the command line. That means that all the following uses work:</p> </div> <div class="listingblock"> <div class="content"> <pre>$ git foo --long-opt=Arg $ git foo --long-opt Arg $ git foo -oArg $ git foo -o Arg</pre> </div> </div> <div class="paragraph"> <p>However, this is <strong>NOT</strong> allowed for switches with an optional value, where the <em>stuck</em> form must be used:</p> </div> <div class="listingblock"> <div class="content"> <pre>$ git describe --abbrev HEAD # correct $ git describe --abbrev=10 HEAD # correct $ git describe --abbrev 10 HEAD # NOT WHAT YOU MEANT</pre> </div> </div> </div> </div> </div> <div class="sect1"> <h2 id="_notes_on_frequently_confused_options"><a class="anchor" href="#_notes_on_frequently_confused_options"></a>NOTES ON FREQUENTLY CONFUSED OPTIONS</h2> <div class="sectionbody"> <div class="paragraph"> <p>Many commands that can work on files in the working tree and/or in the index can take <code>--cached</code> and/or <code>--index</code> options. Sometimes people incorrectly think that, because the index was originally called cache, these two are synonyms. They are <strong>not</strong> — these two options mean very different things.</p> </div> <div class="ulist"> <ul> <li> <p>The <code>--cached</code> option is used to ask a command that usually works on files in the working tree to <strong>only</strong> work with the index. For example, <code>git grep</code>, when used without a commit to specify from which commit to look for strings in, usually works on files in the working tree, but with the <code>--cached</code> option, it looks for strings in the index.</p> </li> <li> <p>The <code>--index</code> option is used to ask a command that usually works on files in the working tree to <strong>also</strong> affect the index. For example, <code>git stash apply</code> usually merges changes recorded in a stash entry to the working tree, but with the <code>--index</code> option, it also merges changes to the index as well.</p> </li> </ul> </div> <div class="paragraph"> <p><code>git apply</code> command can be used with <code>--cached</code> and <code>--index</code> (but not at the same time). Usually the command only affects the files in the working tree, but with <code>--index</code>, it patches both the files and their index entries, and with <code>--cached</code>, it modifies only the index entries.</p> </div> <div class="paragraph"> <p>See also <a href="https://lore.kernel.org/git/7v64clg5u9.fsf@assigned-by-dhcp.cox.net/" class="bare">https://lore.kernel.org/git/7v64clg5u9.fsf@assigned-by-dhcp.cox.net/</a> and <a href="https://lore.kernel.org/git/7vy7ej9g38.fsf@gitster.siamese.dyndns.org/" class="bare">https://lore.kernel.org/git/7vy7ej9g38.fsf@gitster.siamese.dyndns.org/</a> for further information.</p> </div> <div class="paragraph"> <p>Some other commands that also work on files in the working tree and/or in the index can take <code>--staged</code> and/or <code>--worktree</code>.</p> </div> <div class="ulist"> <ul> <li> <p><code>--staged</code> is exactly like <code>--cached</code>, which is used to ask a command to only work on the index, not the working tree.</p> </li> <li> <p><code>--worktree</code> is the opposite, to ask a command to work on the working tree only, not the index.</p> </li> <li> <p>The two options can be specified together to ask a command to work on both the index and the working tree.</p> </li> </ul> </div> </div> </div> <div class="sect1"> <h2 id="_git"><a class="anchor" href="#_git"></a>GIT</h2> <div class="sectionbody"> <div class="paragraph"> <p>Part of the <a href='/docs/git'>git[1]</a> suite</p> </div> </div> </div> <h3 hidden="true" data-pagefind-weight="10">gitcli</h3> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/application.min.js"></script> </div> </body> </html>