I currently have three modified files in my working directory. However I want one of them to be reset to the HEAD status.
In SVN, I'd use svn revert <filename>
(followed by svn update <filename>
if needed) but in Git I should use git reset --hard
. However this command cannot operate on a single file.
Is there any way in Git to discard the changes to a single file and overwrite it with a fresh HEAD copy?
Best Answer
You can use the following command:
... which will update both the working copy of
my-file.txt
and its state in the index with that from HEAD.--
basically means: treat every argument after this point as a file name. More details in this answer. Thanks to VonC for pointing this out.