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

Re: [PATCH v2] replay: drop commits that become empty

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 17, 2025, 23:49 UTC
Message-ID
<xmqqtsxozn2a.fsf@gitster.g>
In-Reply-To
<d54c50ef-9d6c-498c-aca3-ed4461733190@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 10 quoted lines
>> 	git commit --allow-empty --only -m empty
>> 
>> because without --only, the changes to blah will be taken.
>
> I've got into the habit of always adding "--only" when I want to create 
> an empty commit in case there are staged changes. I don't really like 
> "--allow-empty" as I've never wanted to create commit that might or 
> might not be empty - either I want to create an empty commit in which 
> case I don't want to commit any staged changes, or I want the commit to 
> fail if there are no staged changes). I can remove it if you want.

Being explicit when you are unsure is good, but in this script I think we should be very sure that the index matches HEAD, so I would consider that the only effect of the use of the "--only" here is to puzzle readers.

A comment "# force an empty commit by including no paths" before the command would work to help unpuzzle readers, though ;-)

Thanks.
Previous: Phillip WoodNext: Elijah Newren
Message 10 of 16 in “replay: drop commits that become empty”
  1. replay: drop commits that become emptyPhillip Wood, Nov 27, 2025
  2. Junio C HamanoNov 28, 2025
  3. Phillip WoodDec 4, 2025
  4. Elijah NewrenNov 28, 2025
  5. Phillip WoodDec 4, 2025
  6. replay: drop commits that become emptyPhillip Wood, Dec 15, 2025
  7. Junio C HamanoDec 15, 2025
  8. Phillip WoodDec 16, 2025
  9. Phillip WoodDec 17, 2025
  10. Junio C HamanoDec 17, 2025
  11. Elijah NewrenDec 16, 2025
  12. replay: drop commits that become emptyPhillip Wood, Dec 16, 2025
  13. Elijah NewrenDec 16, 2025
  14. Phillip WoodDec 17, 2025
  15. replay: drop commits that become emptyPhillip Wood, Dec 18, 2025
  16. Junio C HamanoDec 19, 2025

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.