How do I discard changes in my working copy that are not in the index?
Git – How to discard unstaged changes in Git
gitversion control
Related Topic
- Git – How to undo ‘git add’ before commit
- Git – How to undo the most recent local commits in Git
- Git: How to force “git pull” to overwrite local files
- Git – How to make Git “forget” about a file that was tracked, but is now in .gitignore
- Git – How to check out a remote Git branch
- Git – How to delete a Git branch locally and remotely
- Git – How to revert a Git repository to a previous commit
- Git – How to rename a local Git branch
Best Answer
For all unstaged files in current working directory use:
For a specific file use:
--
here to remove ambiguity (this is known as argument disambiguation).For Git 2.23 onwards, one may want to use the more specific
resp.
that together with
git switch
replaces the overloadedgit checkout
(see here), and thus removes the argument disambiguation.