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

Re: git-rebase eats empty commits

From
Michael J Gruber <michaeljgruber+gmane@fastmail.fm>
Date
Jul 14, 2008, 15:01 UTC
Message-ID
<g5fpnm$3jb$1@ger.gmane.org>
In-Reply-To
<20080712221207.GB22323@leksak.fem-net>
Stephan Beyer venit, vidit, dixit 13.07.2008 00:12:
Show 36 quoted lines
> Hi,
> 
> Michael J Gruber wrote:
>> "git commit" allows empty commits with the "--allow-empty" option, i.e.  
>> commits which introduce no change at all. This is sometimes useful for  
>> keeping a log of untracked work related to tracked content.
>>
>> "git rebase" removes empty commits, for the good reason that rebasing  
>> may make certain commits obsolete; but I don't want that in the case  
>> mentioned above. Is there any way to specify "--preserve-empty" or 
>> similar?
> 
> First I can speak for git-sequencer: there is no such thing as a
> "preserve empty" option, but currently, when you are picking a commit
> that has already been applied so that no changes occur, it will pause.
> (It will not pause if it is a fast-forward.)
> Yet, I was unsure if this is a "correct" behavior, but it seemed to be
> useful, because you can inspect the situation.
> 
> In my mind, the same should happen with an empty commit, so I tested it:
>  1. It pauses.
>  2. In that pause I only need to run "git commit --allow-empty" and I have
>     the picked empty patch with that commit message.
> 
> So if this behavior is kept, there is no such need for such an option.
> 
> Now I'm checking it with the old rebase-i (I'm always referring to
> git-rebase--interactive as rebase-i) and exactly the same behavior
> occurs.
> 
> But rebase is not rebase-i.
> So I've also checked both, pure rebase and rebase-m: then the empty commit
> is lost.
> 
> To sum up, use rebase -i and when it's pausing, do "git commit --allow-empty"
> and then "git rebase --continue" and you have what you want.

I assume this is with git from master? With git 1.5.6.2 rebase -i doesn't stop there, not even when I change "pick" to "edit"!

So, I guess for now I'll use my hacked git-rebase ("-m", I didn't hack git-format-patch), maybe 1.6.0 will behave as described above. Anyway thanks for the hint about distinguishing between rebase and rebase -i.

Michael
Previous: Stephan BeyerNext: Stephan Beyer
Message 3 of 5 in “git-rebase eats empty commits”
  1. Michael J GruberJul 8, 2008
  2. Stephan BeyerJul 12, 2008
  3. Michael J GruberJul 14, 2008
  4. Stephan BeyerJul 15, 2008
  5. Michael J GruberJul 16, 2008

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.