git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Modify/edit old commit messages

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 1, 2007, 16:41 UTC
Message-ID
<Pine.LNX.4.64.0702010829560.3632@woody.linux-foundation.org>
In-Reply-To
<Pine.LNX.4.63.0702011326130.22628@wbgn013.biozentrum.uni-wuerzburg.de>
On Thu, 1 Feb 2007, Johannes Schindelin wrote:
Show 6 quoted lines
> 
> On Thu, 1 Feb 2007, Rodolfo Giometti wrote:
> > 
> > I'm puzzled... how can I modify or edit old commit messages? :)
> 
> Short answer: you can't.
Side note, just out of historical interest: in BK you could.

And if you're used to it (like I was) it was really quite practical. I would apply a patch-bomb from Andrew, notice something was wrong, and just edit it before pushing it out.

I could have done the same with git. It would have been easy enough to make just the commit message not be part of the name, and still guarantee that the history was untouched, and allow the "fix up comments later" thing.

But I didn't.

Part of it is purely "internal consistency". Git is simply a _cleaner_ system thanks to everything being SHA1-protected, and all objects being treated the same, regardless of object type. Yeah, there are four different kinds of objects, and they are all really different, and they can't be used in the same way, but at the same time, even if their encoding might be different on disk, *conceptually* they all work exactly the same.

But internal consistency isn't really an excuse for being inflexible, and clearly it would be very flexible if we could just fix up mistakes after they happen. So that's not a really strong argument.

The *real* reason git doesn't allow you to change the commit message ends up being very simple: that way, you can trust the messages. If you allowed people to change them afterwards, the messages are inherently not very trustworthy.

In BK, for example, if you edited the commit message after already pushing it out, it would *work*, but the stuff you pushed out would obviously not be changed, so different repositories would literally have different commit messages. I did it anyway a few times when some really irritating typo just made me say "I can't stand reading that typo over and over again, I'll fix it in my tree and screw everybody else".

But it's also very important because nobody *else* can mess with your history without it being obvious to everybody who has ever seen the pristine one, and nobody can change what you said later. Yeah, there's a few embarrassing typo's in the kernel history. We'll never be able to live down the fact that spelling and grammar is the dificultest for us. And we have some bugs where people have corrupt email addresses etc.

And I'll take guaranteed history over typos any day. 
			Linus
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 5 in “Modify/edit old commit messages”
  1. Rodolfo GiomettiFeb 1, 2007
  2. Johannes SchindelinFeb 1, 2007
  3. Linus TorvaldsFeb 1, 2007
  4. Johannes SchindelinFeb 1, 2007
  5. Jakub NarebskiFeb 1, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.