Privacy Policy
© 2025 linux101.dev

Git: Fix an Older Commit

To fix the message of a commit that is not the most recent one, you can use interactive rebase.

CommandDescription
git rebase -i HEAD~NStart an interactive rebase, where N is the number of commits back you want to go.

After running the command, an editor will open. Change the word pick to reword (or r) next to the commit you want to edit.

    pick abc123 Old commit message
    reword abc123 Another old commit message
    

Save and close the editor. A new editor will open, allowing you to enter the new commit message.

⚠️ If You Already Pushed:
Since rebasing rewrites history, you will need to force-push to update the remote branch:
git push --force

Use with caution, as it can cause issues for others working on the same branch.