Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The special "option" <code>--</code> means "treat every argument after this point as a file name, no matter what it looks like." This is not Git-specific, it's a general Unix command line convention. Normally you use it to clarify that an argument is a file name rather than an <em>option</em>, e.g.</p> <pre><code>rm -f # does nothing rm -- -f # deletes a file named "-f" </code></pre> <p><code>git checkout</code><sup>1</sup> also takes <code>--</code> to mean that subsequent arguments are not its optional "treeish" parameter specifying which commit you want.</p> <p>So in this context it's <em>safe</em> to use <code>--</code> always, but you <em>need</em> it when the file you want to revert has a name that begins with <code>-</code>, or is the same as the name of a branch. Some examples for branch/file disambiguation:</p> <pre><code>git checkout README # would normally discard uncommitted changes # to the _file_ "README" git checkout master # would normally switch the working copy to # the _branch_ "master" git checkout -- master # discard uncommitted changes to the _file_ "master" </code></pre> <p>and option/file disambiguation:</p> <pre><code>git checkout -p -- README # interactively discard uncommitted changes # to the file "README" git checkout -- -p README # unconditionally discard all uncommitted # changes to the files "-p" and "README" </code></pre> <p>I'm not sure what you do if you have a <em>branch</em> whose name begins with <code>-</code>. Perhaps don't do that in the first place.</p> <hr> <p><sup>1</sup> in this mode; "checkout" can do several other things as well. I have never understood why git chose to implement "discard uncommitted changes" as a mode of the "checkout" subcommand, rather than "revert" like most other VCSes, or "reset" which I think might make more sense in git's own terms.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload