All fixes

Help, I made a typo in my last commit message

Fix the message of your last commit with one command, and know when it is safe to push the change.

The fix

  1. git commit --amend -m "Fix login redirect"

    Replaces the last commit with a copy that has the new message. Anything you staged goes in too, so check git status first.

Fix login redirect is an example. Replace it with your own.

What happens to your historygit commit --amend -m "Fix login redirect"
BeforeABCHEADmain
AfterABC′HEADmain

Why this works

Commits cannot be edited, so --amend builds a new commit with the same changes and your new message and puts it where the old one was. That is why the hash changes. If nobody has the old commit yet, nobody notices. If you already pushed it, the remote still has the old one, which is why you need a force push, and why you should only do that on a branch nobody else works on.