Basically git reset command helps to reset current HEAD to specified state. It can be used for instance to undo X commits or merges. But it can also be used to reset a single file in the index.
Let's imagine that we've just created new file in our local repository:
bartosz:~/workspace/git_tests/git_reset_dash_dash$ touch new_file.txt bartosz:~/workspace/git_tests/git_reset_dash_dash$ git status On branch master Initial commit Untracked files: (use "git add..." to include in what will be committed) new_file.txt nothing added to commit but untracked files present (use "git add" to track) bartosz:~/workspace/git_tests/git_reset_dash_dash$ git add new_file.txt bartosz:~/workspace/git_tests/git_reset_dash_dash$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached ..." to unstage) new file: new_file.txt
Now, let's suppose that we want to create and commit README.md before new_file.txt. Of course, we can commit 2 files independently but we want to test double dashes in git reset:
bartosz:~/workspace/git_tests/git_reset_dash_dash$ touch README.md bartosz:~/workspace/git_tests/git_reset_dash_dash$ git add README.md bartosz:~/workspace/git_tests/git_reset_dash_dash$ git reset -- new_file.txt bartosz:~/workspace/git_tests/git_reset_dash_dash$ git commit -m "add README.md" [master (root-commit) 59896e1] add README.md 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md bartosz:~/workspace/git_tests/git_reset_dash_dash$ git status On branch master Untracked files: (use "git add..." to include in what will be committed) new_file.txt nothing added to commit but untracked files present (use "git add" to track) bartosz:~/workspace/git_tests/git_reset_dash_dash$ git add new_file.txt bartosz:~/workspace/git_tests/git_reset_dash_dash$ git commit -m "add new_file.txt" [master 36fd84e] add new_file.txt 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 new_file.txt bartosz:~/workspace/git_tests/git_reset_dash_dash$ git status On branch master nothing to commit, working directory clean
As you can see, the double dashes (--) helps to separate paths from revisions and undo the state of added or removed files.