Discarding changes in working directory in Git

To discard changes in working tree to make it clean, a safer way is to use stash command. stash takes the changes in working directory away and you can get them back later.

# Stash changes in working directory
$ git stash

# Apply the latest stashed changes
$ git stash apply

Read stashing changes for more about how to use stash.

If you still want to discard the changes directly, use below command (Changes can not be recovered):

# Discard the changes in working directory and staging area.
# Be aware that changes can not be recovered.
$ git reset --hard