If a path is specified, reset does not move the HEAD because it does not make sense to move the HEAD, if only a part of the commit needs to be reset.
To move a file from HEAD to the index:
$ git reset file.txt
It is a shortform for:
$ git reset --mixed HEAD file.txt
Do demonstrate the effect of the command, let's start from here:
$ git log --oneline --decorate 5a4e185 (HEAD, master) V3 bd670b5 V2 1532be9 V1
Then we change the contents of file.txt to "V4" and stage the modification:
$ echo V4 > file.txt $ git add file.txt $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: file.txt
The reset-with-path command is used to unstage the change:
$ git reset file.txt Unstaged changes after reset: M file.txt $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: file.txt
These commands are equivalent:
$ git reset file.txt $ git reset 5a4e185 file.txt $ git reset 5a4e185 -- file.txt