If you want to just cancel commit, you can use this script bellow :
git reset HEAD~1
But if you want to cancel and discard all changes, you can add flag --hard, this flag will also make git discard all changes you made.
git reset --hard HEAD~1
Source : https://stackoverflow.com/questions/4850717/how-to-cancel-a-local-git-commit
zuka.one
©2011