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 usegit 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 viagit add, simply issue thegit commitcommand.git commit[-m message]To ignore whatever you have added via
git addand 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 usegit log -- filename
You need to check the man pages for any git command you use if you need to understand its specific meaning.