Cancel 1 last commit, and keep the changes:
git reset HEAD~1
Can replace the number 1 to cancel more than one commit at once:
git reset HEAD~5
Can cancel the commit and remove the changes (dangerous) :
git reset HEAD~1 --hard
Add files to your previous commit:
git add .
git commit --amend --no-edit
Edit your previous commit message:
git commit --amend