Discarding unstaged changes in Git
Start your free 7-days trial now!
To discard unstaged changes in Git you can use the
git checkout command. This is useful when you have made changes to a file that have not yet been staged and you would like to undo them.
To discard all unstaged changes in the current working directory:
git checkout -- .
To discard all unstaged changes for a particular file:
git checkout -- <filepath>
<filepath> refers to the filepath of the file you would like to remove all unstaged changes for.
Be careful when using this command as once changes are discarded they cannot be recovered.