Editing a message of a pushed commit

alvesjessica

Jessica Alves

Posted on August 4, 2023

Editing a message of a pushed commit

This is a quick post for those situations where you just pushed a commit to your branch and then realized the commit message is not clear, or there's some misspelling. Whatever is the reason you want to edit it, here are two quick steps.

Make sure you're in the intended branch and first run:

git commit --amend -m "Your new commit message"

Then run:

git push --force

Done.

If you run git log you'll be able to check your updated commit message.

Don’t amend public commits
"Amended commits are actually entirely new commits and the previous commit will no longer be on your current branch. This has the same consequences as resetting a public snapshot. Avoid amending a commit that other developers have based their work on. This is a confusing situation for developers to be in and it’s complicated to recover from."
(Atlassian's tutorial)

See more

Read the GitHub docs for more information or this tutorial from Atlassian.

💖 💪 🙅 🚩
alvesjessica
Jessica Alves

Posted on August 4, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related