Git: what is the "right way" to fix an incorrect pushed commit message

I wrote the wrong commit message and I pushed it to the remote. There are not many questions that already deal with this:

- just a couple. But they all end up with git push --force

an additional warning as to why this is a bad idea - it edits history, which means everyone else who uses the repository suffers when they try. They don't seem to be saying what to do "right."

So what's the recommended or "correct" way to handle this situation? I thought I'd add an additional post with git commit --allow-empty

, but presumably "is rarely a good reason for this ." Is it really the --allow-empty

right way to fix the situation? If not, what is the correct path?

Note . Doing the "right way" can involve "admitting that I squinted." As an example of what I'm looking for, the man page git tag

has a discussion on retagging . It clearly discusses techniques for re-marking incorrectly flagged commits, giving both a recommended course of action and a --force

-iish way of doing things.

+3


source to share


1 answer


One thing you can do is add a note to the commit, eg. git notes add -m "Here is my note" head~1

... This will show up in git log

without actually changing the commit. Another alternative is to add an annotated tag to the commit, eg. git tag -a tag-summary -m "Here are the tag details" head~1

... I prefer to use the tag as tags are displayed in the log view of most tools, while notes are not displayed (although they are displayed in git log

).



+6


source







All Articles