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

Re: [BUG] - "git commit --amend" commits, when exiting the editor with no changes written

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 2, 2010, 23:44 UTC
Message-ID
<7vfx5j19vg.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.1.00.1002022356460.4985@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 5 quoted lines
> No. If not saving, then it means that the user was fine with the message 
> as-is.
>
> Remember, --amend is usually for amending the _content_ of the patch, not 
> so much the message.

I very often use --amend to update only the message, so I would strongly disagree with the "usually".

But that doesn't change my conclusion ;-) It is immaterial if you amended the tree or the message. If either or both changed, we do need to create a new commit---there is no question about it, so which one is more often done does not matter. Eugene does not gain anything by "Remember"ing it.

What is more important is what to do when neither changed.

If you run "rebase -i" and leave the earlier "pick"s intact, it seems to try keeping the commits intact, instead of rewriting.

It is understandable if somebody wanted to keep using the old commit object when the committer timestamp is the _only_ thing that is different between the original and the amended commit, after "git commit --amend" is run. Essentially, the behaviour of "rebase -i" for earlier "pick"s comes from the same motivation.

Right now, if you run this in a loop:
    while hell has not frozen over
    do
	git reset && EDITOR=: git commit --amend
    done

it will keep generating almost identical commits, except for their committer timestamps. The very first one may have different committer identity from the original if you are amending somebody else's commit, but after that it will be all you over and over again, only at different times.

I am inclined to say that it is a feature that it updates the commit in such a case to record the _last time_ you touched the commit. You ran "commit --amend" and did not use the any published method to _abort_ the amend.

As mentioned already, @{1} is your friend. Regardless of the difference between @{0} and @{1}, it is a way to go back to the previous commit if you do not like the latest commit for whatever reason; the latest commit may have a "wrong tree", a "wrong message", or a "wrong committer timestamp".

Previous: Paolo BonziniNext: Avery Pennarun
Message 44 of 45 in “[BUG] - "git commit --amend" commits, when exiting the editor with no changes written”
  1. Eugene SajineFeb 2, 2010
  2. Jacob HelwigFeb 2, 2010
  3. Avery PennarunFeb 2, 2010
  4. Eugene SajineFeb 2, 2010
  5. Wincent ColaiutaFeb 2, 2010
  6. Eugene SajineFeb 2, 2010
  7. Erik Faye-LundFeb 2, 2010
  8. Wincent ColaiutaFeb 2, 2010
  9. Eugene SajineFeb 2, 2010
  10. Avery PennarunFeb 2, 2010
  11. Eugene SajineFeb 2, 2010
  12. Johannes SchindelinFeb 2, 2010
  13. Eugene SajineFeb 2, 2010
  14. Avery PennarunFeb 2, 2010
  15. Larry D'AnnaFeb 3, 2010
  16. Jeff KingFeb 3, 2010
  17. Jeff KingFeb 3, 2010
  18. Avery PennarunFeb 3, 2010
  19. Johannes SchindelinFeb 2, 2010
  20. Eugene SajineFeb 2, 2010
  21. Erik Faye-LundFeb 2, 2010
  22. Eugene SajineFeb 2, 2010
  23. Erik Faye-LundFeb 3, 2010
  24. Eugene SajineFeb 3, 2010
  25. SZEDER GáborFeb 3, 2010
  26. Matthieu MoyFeb 3, 2010
  27. aborting rebase -i right at the start, was Re: [BUG] - "git commit --amend" commits, when exiting the editor with no changes writtenJohannes Schindelin, Feb 3, 2010
  28. SZEDER GáborFeb 3, 2010
  29. Eugene SajineFeb 3, 2010
  30. Matthieu MoyFeb 3, 2010
  31. Eugene SajineFeb 3, 2010
  32. Jonathan NiederFeb 3, 2010
  33. Jonathan NiederFeb 3, 2010
  34. Wincent ColaiutaFeb 3, 2010
  35. Eugene SajineFeb 3, 2010
  36. Avery PennarunFeb 3, 2010
  37. Eugene SajineFeb 3, 2010
  38. Avery PennarunFeb 3, 2010
  39. Matthieu MoyFeb 3, 2010
  40. Johannes SchindelinFeb 2, 2010
  41. Eugene SajineFeb 3, 2010
  42. Johannes SchindelinFeb 3, 2010
  43. Paolo BonziniFeb 3, 2010
  44. Junio C HamanoFeb 2, 2010
  45. Avery PennarunFeb 2, 2010

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.