Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the double-dash [--] option do on git reset?

Tags:

git

git-reset

I've seen commands like:

git reset e542 -- readme.txt

I understand this command puts in the index the contents of the file readme.txt from commit e542. But what's the -- option doing there?

The git reset man page lists it as optional for the first two forms but I couldn't find what it means.

git reset [-q] [<commit>] [--] <paths>…
git reset (--patch | -p) [<commit>] [--] [<paths>…]
like image 340
AngraX Avatar asked Jan 08 '13 15:01

AngraX


1 Answers

-- separates branch names from file names, in case there is any ambiguity (if you have a branch and a file with the same name). If there are no ambiguities, you don't need the --.

Also as mentioned by Jonas Wielicki, this allows for file names that start with a -; these would otherwise be interpreted as command-line options.

like image 88
Anders Johansson Avatar answered Oct 11 '22 10:10

Anders Johansson