Discard Git Stash Pop

Reset can also be called on specific files :

git reset HEAD <filename>...

You can't hard reset a file though. But you can revert the changes with checkout afterwards :

git checkout -- <filename>...

You stash will be preserved, as pointed out by Luke in MichaelMilom answer.

This is useful when you don't want to lose your un-committed local changes.


This has already been asked and answered on stackoverflow (see How to revert Git repository to a previous commit?), but the simple answer is:

git reset --hard HEAD

This should take care of your problem. Note that this removes all uncommitted changes from the repository.

Note that if there are conflicts, the stash is preserved. From the stash docs:

Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.

Tags:

Git