Amend the Last Commit
Git · Undoing Changessyntax
git commit --amend [-m "new message"]example
# Fix the commit message:
git commit --amend -m "Add user auth endpoint with JWT support"
# Add forgotten files to the last commit:
git add forgotten-file.js
git commit --amend --no-editoutput
[main b2c3d4e] Add user auth endpoint with JWT supportNote WARNING: Amending rewrites the commit hash. Never amend a commit that has already been pushed to a shared branch — other developers who pulled the original commit will have conflicts. Use git revert instead for pushed commits.