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

Re: [PATCH] cherry-pick: when pick fails, explain how to cancel

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Feb 18, 2011, 21:38 UTC
Message-ID
<4D5EE6BB.9070507@gmail.com>
In-Reply-To
<20110218012435.GA16893@elie>
W dniu 18.02.2011 02:24, Jonathan Nieder pisze:
Show 6 quoted lines
> Piotr Krukowiecki wrote:
>> 1. add hint to cherry-pick how to abort merge, for example:
>>    hint: use 'git reset --merge ORIG_HEAD' to abort merge
> 
> Good idea.  "git cherry-pick" does not set ORIG_HEAD, so I
> put "git reset --merge HEAD" instead.

You're right. I was sure I have tested it, but when I try to use ORIG_HEAD now it does not work.

I took it from Documentation/git-cherry-pick.txt, which seem to be wrong:

   $ git cherry-pick topic^             <1>
   $ git diff                           <2>
   $ git reset --merge ORIG_HEAD        <3>
   [...]
   <3> cancel the cherry-pick.  In other words, return to the
   pre-cherry-pick state, preserving any local modifications you had in
   the working tree.
Show 6 quoted lines
>> 2. add hint to status how to abort merge, for example:
>>    #   (use 'git reset --merge ORIG_HEAD' to abort merge)
> 
> "git reset --merge" will remove local changes marked with "git add",
> under the assumption that they were part of the conflict resolution
> and thus should be cleared away.

Didn't know that (one probably shouldn't merge with uncommitted/local changes anyway). git-reset.txt mentions it, but there's no explicit warning.

Show 16 quoted lines
> This leaves me afraid of the following scenario:
> 
> 	git pull
> 	# conflict?  agh!
> 
> 	# ... two days later ...
> 	... hack hack hack ...
> 	... add add add ...
> 	git commit;	# fails because of unmerged files
> 
> 	# whoops, forgot about that merge.
> 	# Let's do what it says to do:
> 	git reset --merge ORIG_HEAD
> 
> It seems safest to only recommend "reset --merge" immediately
> after a mergy operation.

Is it possible to recognize that you have something more than what was cause by the merge/cherry-pick?

Show 5 quoted lines
>> The ORIG_HEAD is specified in man page example.
> 
> I assume you mean on the git-reset page?  It might be nice to add
> more examples and to update the current ones with current best
> practice (e.g., using reset --keep more often).
Yes, it says:
   Running "git reset --hard ORIG_HEAD" will let you go back to where
   you were, but it will discard your local changes, which you do not
   want.  "git reset --merge" keeps your local changes.
 
>> git-cherry-pick uses word "cancel" in man page (in example) and
>> git-merge uses word "abort" for (as I understand) the same action.
> 
> Hmm, where is this example in the cherry-pick manpage?

It's in the Documentation/cherry-pick.txt (in current master). I assume man pages are generated from those text files. I have also cited it at the beginning of this mail.

-- 
Piotr Krukowiecki
Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 5 in “Aborting cherry-pick”
  1. Piotr KrukowieckiFeb 16, 2011
  2. cherry-pick: when pick fails, explain how to cancelJonathan Nieder, Feb 18, 2011
  3. Piotr KrukowieckiFeb 18, 2011
  4. Documentation: cherry-pick does not set ORIG_HEADJonathan Nieder, Feb 18, 2011
  5. Piotr KrukowieckiFeb 19, 2011

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.