I have a modified file in a Git working directory which I want to discard. This file is not in a submodule.
I tried 3 different commands and nothing helped.
git checkout -- <file>
, or git checkout <file>
git reset HEAD --hard
git stash save --keep-index
How to discard that file?
Screenshots:
As long as you set git config --global core.autocrlf true
, you will see changes applied automatically to those file.
I would recommend:
core.autocrlf
to false
core.eol
directive in a .gitattributes
file for the specific files or types of files you want to be handled (in term of EOL style).