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

rebase -i might leave CHERRY_PICK_HEAD behind

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jun 16, 2015, 12:06 UTC
Message-ID
<20150616140612.Horde.a1irZQmh2o42SqDfxAytHg1@webmail.informatik.kit.edu>
Hi,

When skipping an empty commit with 'git rebase --continue' a CHERRY_PICK_HEAD file might be left behind.

What I did boils down to this:
     echo one >file
     git add file
     git commit -m first
     echo two >file
     git commit -a -m second
     echo three >file
     git commit -a -m third
     git rebase -i HEAD^^
     # change todo list to edit the "second" commit
     echo three >file
     git commit -a --amend
     # this effectively makes the third commit an empty commit
     # and rebase will ask what to do:
     git rebase --continue
     The previous cherry-pick is now empty, possibly due to conflict  
resolution.
     If you wish to commit it anyway, use:
         git commit --allow-empty
     Otherwise, please use 'git reset'
     rebase in progress; onto 7335bbe7a5
     You are currently rebasing branch 'master' on '7335bbe7a5'.
     nothing to commit, working directory clean
     Could not apply d19f82ac6d467247117fd734ed039b03ef923c86... third
     # I didn't want an empty commit, but didn't read that carefully, so I did:
     git rebase --continue
     Successfully rebased and updated refs/heads/master.
     # and was rewarded for my lack of attention with the following  
bash prompt:
     test/rebase-empty-continue (master|CHERRY-PICKING)$
     # indeed:
     ls -l .git/CHERRY_PICK_HEAD
     -rw-r--r-- 1 szeder szeder 41 Jun 16 13:22 .git/CHERRY_PICK_HEAD

On one hand, it's user error: it told me to run 'git reset' to achive what I want but I didn't. Note, however, how it told me about 'git reset': while 'git commit --allow-empty' is greatly emphasized by indentation and empty lines before and after, 'git reset' blends in quite well into the rebase progress. It was late, I was tired, and there was a questionable penalty on Copa América as well ;), so I simply didn't notice.

On the other hand,
    1. 'git rebase' claimed that "Successfully rebased...", yet it left
       cruft behind.  I think it shouldn't.
    2. 'git rebase --continue' didn't complain by the lack of prior
       'git reset' and finished doing exacly what I expected from it to
       do (except leaving CHERRY_PICK_HEAD behind, of course).
       Perhaps it should complain, like it does when the worktree is
       dirty.
       Alternatively, it could just continue to DWIM, as it does
       already, but then it should remove CHERRY_PICK_HEAD as well.
Gábor
Next: Johannes Schindelin
Message 1 of 20 in “rebase -i might leave CHERRY_PICK_HEAD behind”
  1. SZEDER GáborJun 16, 2015
  2. Johannes SchindelinJun 16, 2015
  3. 0/2 rebase -i: Fix left-behind CHERRY_PICK_HEADJohannes Schindelin, Jun 17, 2015
  4. 1/2 t3404: demonstrate CHERRY_PICK_HEAD bugJohannes Schindelin, Jun 17, 2015
  5. Junio C HamanoJun 17, 2015
  6. Johannes SchindelinJun 18, 2015
  7. Junio C HamanoJun 18, 2015
  8. Johannes SchindelinJun 18, 2015
  9. 2/2 rebase -i: do not leave a CHERRY_PICK_HEAD file behindJohannes Schindelin, Jun 17, 2015
  10. SZEDER GáborJun 17, 2015
  11. Johannes SchindelinJun 17, 2015
  12. Junio C HamanoJun 17, 2015
  13. 0/2 rebase -i: Fix left-behind CHERRY_PICK_HEADJohannes Schindelin, Jun 18, 2015
  14. 1/2 t3404: demonstrate CHERRY_PICK_HEAD bugJohannes Schindelin, Jun 18, 2015
  15. 2/2 rebase -i: do not leave a CHERRY_PICK_HEAD file behindJohannes Schindelin, Jun 18, 2015
  16. 0/2 rebase -i: Fix left-behind CHERRY_PICK_HEADJohannes Schindelin, Jun 18, 2015
  17. 1/2 t3404: demonstrate CHERRY_PICK_HEAD bugJohannes Schindelin, Jun 18, 2015
  18. 2/2 rebase -i: do not leave a CHERRY_PICK_HEAD file behindJohannes Schindelin, Jun 18, 2015
  19. Junio C HamanoJun 18, 2015
  20. Johannes SchindelinJun 18, 2015

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.