Amend
In one line
Amending modifies the last commit — it can add forgotten changes or change the commit message without creating a new commit.
In simple words
git commit --amend modifies the most recent commit instead of creating a new one. It is useful for two scenarios: (1) you forgot to stage a file and want to add it to the last commit, and (2) you want to fix a typo in the last commit message.
Amend creates a new commit with a new hash that replaces the old one. The old commit becomes unreachable. This is fine if you have not pushed the commit yet. If you have already pushed, you must force-push to update the remote, which can cause problems for others.
Common usage: git add forgotten-file.js && git commit --amend --no-edit adds a file to the last commit without changing the message. git commit --amend -m "New message" changes only the message. Never amend commits that have been pushed to shared branches.
Example
# Add a forgotten file to the last commit
git add forgotten.js
git commit --amend --no-edit
# Change the last commit message
git commit --amend -m "Better commit message"amend modifies the last commit. Do not amend pushed commits.
Related terms
Related Resources
Related Lessons
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.