Using git-replace to edit a commit message?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A somewhat common question with Git is how to change a commit message of an
already created commit. 

When this question comes up, the most common case is an unpublished commit,
which can safely be corrected by re-writing history.

Occasionally the question is about a published commit. Sometimes even for
published repositories rewriting history is acceptable, but often it is not.
In that case the usual answer is either: there is nothing you can do without
rewriting history, or add a note to the commit.

Is that really true?

It occurs to me that the following procedure should work rather well for
this, as long as it is not a frequent occurrence.

Create a new commit object with the correct text (or correct author,
or correct committer), ensuring that the the listed tree and parent
SHA-1 hashes are correct (i.e. are the same those hashes in the commit
being "edited").

Then simply use git-replace to have all references to the "unedited"
commit instead use this new commit.

Is there some reason that will not work? If it would work, is there
some reason nobody ever seems to suggest it?

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]