gitatlassian-sourcetree

In SourceTree, can you change a commit comment without changing the commit?


I like to use SourceTree for git, and I put a typo in the comments for a commit. I meant to have it begin with [US-1234] but dropped the leading [ so it came out US-1234].

Is there an easy way to update the comment without doing anything to the commit?

Thanks.


Solution

  • Is there an easy way to update the comment without doing anything to the commit?

    There is no way to change a commit in any way whatsoever, period. That is one of the basic laws of Git. If that were not so, the history would become fragile; the point of Git is to preserve history. If you "update the comment" you will in fact be making a different commit, and you will know this because the SHA for that commit will appear to have changed. It hasn't actually changed; the commit with a different comment is in fact a new and different commit.

    Moreover, if this commit is the parent / ancestor of any later commits, they will all be replaced in the same way. That's because a commit's parentage is part of what it is, so it, too, cannot be changed. Therefore, if you change what commit goes in this spot, then all new child commits will be created so as to have this new commit as their parent / ancestor instead of the old one.

    All that said, amending the comment of a commit is easy in Sourcetree.