When the files are only staged and you want to unstage, just use git reset
for that as @neuroine answered:
git reset /path/to/file
But if you created just one commit but now want to soft reset. Using git reset --soft
won't work as it will say:
$ git reset --soft HEAD~
fatal: ambiguous argument 'HEAD~': unknown
revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
In that case, we can use update-ref
:
git update-ref -d HEAD
Keeping this extra detail here even though it was not directly asked in the question because it is a similar problem and people can stumble upon this and find solution here.