3

I need to add several files to group them into a single commit, but I have to exclude one of them. In this answer, the code given to do this is:

git add -u
git reset -- file_to_ignore.dat

I'm not sure what the dashes do in the last command. What is the difference with the following?

git reset file_to_ignore.dat

which is how it's shown in this tutorial.

Community
  • 1
  • 1
Gabriel
  • 40,504
  • 73
  • 230
  • 404

1 Answers1

4

I mentioned that double hyphen (or double dash) notation in "Deleting a badly named git branch".

It helps separating the options of a commands from the actual arguments (filename)

It is also conventional to recognize a double hyphen as a signal to stop option interpretation and treat all following arguments literally.

In your case, there is no difference... unless the file name is 'master'! (in which case, the -- are very important)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250