How to revert local commit ?

When one commit is not pushed to remote branch, it can be reverted with simple git reset command. Below you can find an example to revert the last not pushed commit:

git reset --soft HEAD~1

HEAD~1 means how many commits need to be reverted. We can specify also a specific commit by putting its hash instead of HEAD~X.

Another option, --soft, indicates how the changes should be canceled. Soft revert means that only the commit will be removed but modified files will remain in local repository. In other side, --hard, removes not only commit but also modified files. So it should be used with precaution because some changes can be lost.