git reset or clean or checkout didn't work [duplicate]
For all unstaged files in current working directory use:
git checkout -- .
For a specific file use:
git checkout -- path/to/file/to/revert
--
here to remove ambiguity (this is known as argument disambiguation).
For Git 2.23 onwards, one may want to use the more specific
git restore .
resp.
git restore path/to/file/to/revert
that together with git switch
replaces the overloaded git checkout
(see here), and thus removes the argument disambiguation.
Another quicker way is:
git stash save --keep-index --include-untracked
You don't need to include --include-untracked
if you don't want to be thorough about it.
After that, you can drop that stash with a git stash drop
command if you like.
It seems like the complete solution is:
git clean -df
git checkout -- .
git clean
removes all untracked files (warning: while it won't delete ignored files mentioned directly in .gitignore, it may delete ignored files residing in folders) and git checkout
clears all unstaged changes.