git amend last commit message — rewrite without a new commit
Quick Answer
# Rewrite the last commit message
git commit --amend -m "fix: correct the login redirect URL"
# Open your editor to amend instead of inline
git commit --amend
When to use this
You just committed and noticed a typo in the message, or want to add more detail before pushing.
Other causes & fixes
Add a forgotten file to the last commit
git add forgotten-file.ts
git commit --amend --no-edit # keeps the existing message
Amend a commit that was already pushed
Avoid amending pushed commits on shared branches. If you must, force-push — but only if you are the sole user of the branch.
git commit --amend -m "corrected message"
git push --force-with-lease origin my-branch
Related