With the --hard flag, it allows to undo some work by getting rid of some commits altogether. Unlike most other commands in Git, this actually rewrites the history of your project
Needless to say that this is something that you only want to consider once you are starting to feel really comfortable with Git as it implies loss of data and irreversible actions