In Git, what does `–` (dash dash) mean?

The double dash -- in git means different things to different commands, but in general it separates options from parameters.

In git specifically, the meaning of -- depends on which subcommand you are using it with. It usually separates subcommand arguments (like the branch name in git checkout) from revisions or filenames. Sometimes it is completely optional, and used only to prevent an unusual filename being interpreted as program options.

For Example

  • git checkout. To check out a “commit” (referred to as “tree-ish” in the manual, because you can actually specify a range of object types) you use

    git checkout <commit>

    To refine the checkout to just a file or two, use -- to separate the “tree-ish” parameters from the “filenames” you wish to check out.

  • git commit. To commit whatever is in the “index” (ie, what you have staged via git add, simply issue the git commit command.

    git commit [-m message]

    To ignore whatever you have added via git add and commit the changes in a specific file, use
    git commit -- <filename>

  • git add. To commit a file whose name begins with a - or a --, you must tell git add to stop reading parameters, and start reading filenames; -- does that.

    git add -- -sample.txt

  • git log. To see the commit history restricted to only commits affecting a file use

    git log -- filename

You need to check the man pages for any git command you use if you need to understand its specific meaning.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)