Privacy Policy
© 2025 linux101.dev

Git: Amend Last Commit

Use the --amend flag to modify the most recent commit message. This command is useful for fixing typos or adding changes you forgot to include in the last commit.

CommandDescription
git commit --amendOpens your text editor to allow you to edit the commit message.
git commit --amend -m "New commit title"Directly changes the last commit message without opening an editor.
⚠️ If You Already Pushed:
If you have already pushed your changes, you'll need to force-push after amending the commit:
git push --force

Use this command with extreme caution, especially on shared branches, as it rewrites history.