How do I discard unstaged changes in Git?

Published on Author Code Father
How do I discard unstaged changes in Git? How do I discard changes in my working copy that are not in the index?

For a specific file use:

git checkout path/to/file/to/revert

For all unstaged files use:

git checkout -- .

Make sure to include the period at the end.

————————————–/OR/————————————-

Another quicker way is:

git stash save --keep-index

After that, you can drop that stash with a git stash drop command if you like.

 

Comments

comments

Categories Git