Home / Log
# Change the last commit message
git commit --amend -m "Your new commit message"
# If you've already pushed the commit and need to update the remote
git push --force
Before making changes, verify the current commit history:
git log --oneline -3 # Shows last 3 commits
# or
git log -1 # Shows the most recent commit in detail
To modify the most recent commit message:
git commit --amend -m "Your new commit message"
If you prefer to write a longer message or make more complex edits:
git commit --amend
This will open your default text editor where you can modify the commit message.
If you’ve already pushed the commit to a remote repository:
# First, amend the commit locally
git commit --amend -m "Your new commit message"
# Then force push to update the remote
git push --force
--force-with-lease
instead:git push --force-with-lease
For commits that aren’t the most recent, you’ll need to use an interactive rebase:
# Replace N with how many commits back you want to go
git rebase -i HEAD~N
Then mark the commit you want to change with reword
or r
and save/exit.