threads / discuss / 34146

Is there a way to cherry-pick a merge?

Subject: Is there a way to cherry-pick a merge?

## tl;dr

5 messages between Jun 14, 2013 and Jun 15, 2013.

replies: 4people: 2as markdown or json

George Spelvin· Jun 14, 2013, 19:37 UTC · lore

Sometimes I'd like to repeat a previously performed merge, preserving the commit message. And, if possible, the conflict resolutions.

"git cherry-pick -m 1 <commit>" gets me the changes, but makes an ordinary single-parent commit, not a merge.

"git rebase -p --onto HEAD commit^ commit" does the right thing, but has two annoying properties:

1) It actually checks out "commit", then goes back to HEAD, thus
   forcing a lot of recompiltion of source files that experience
   no net change from the operation.
2) Because it's intended for multi-step use, it stops and waits for
   confirmation if there are rerere changes.  I'd rather it just did the
   commit if there are no remaining conflict markers, and I'll reset or
   amend it if I'm not happy with the result.
Does something like this exist already?
Thank you!
Junio C Hamano· Jun 14, 2013, 19:44 UTC · re: George Spelvin · lore

Re: Is there a way to cherry-pick a merge?

"George Spelvin" <linux@horizon.com> writes:
> Sometimes I'd like to repeat a previously performed merge, preserving
> the commit message.  And, if possible, the conflict resolutions.
Is it "git merge commit^2"?
George Spelvin· Jun 14, 2013, 21:36 UTC · re: Junio C Hamano · lore

Re: Is there a way to cherry-pick a merge?

"George Spelvin" <linux@horizon.com> writes:
>> Sometimes I'd like to repeat a previously performed merge, preserving
>> the commit message.  And, if possible, the conflict resolutions.
> 
> Is it "git merge commit^2"?
I suppose that was an obvious one to leave out of my alternatives list.

This is what I've been doing, but it requires I cut and paste the commit message. Preserving timestamps, author, etc. is even more awkward.

That's why I've been looking for an alternative.
Junio C Hamano· Jun 14, 2013, 21:54 UTC · re: George Spelvin · lore

Re: Is there a way to cherry-pick a merge?

"George Spelvin" <linux@horizon.com> writes:
Show 10 quoted lines
> "George Spelvin" <linux@horizon.com> writes:
>>> Sometimes I'd like to repeat a previously performed merge, preserving
>>> the commit message.  And, if possible, the conflict resolutions.
>> 
>> Is it "git merge commit^2"?
>
> I suppose that was an obvious one to leave out of my alternatives list.
>
> This is what I've been doing, but it requires I cut and paste the commit
> message.  Preserving timestamps, author, etc. is even more awkward.

In the meantime, "git commit --amend -C commit" would be a workaround, I would guess.

George Spelvin· Jun 15, 2013, 03:03 UTC · re: Junio C Hamano · lore

Re: Is there a way to cherry-pick a merge?

> In the meantime, "git commit --amend -C commit" would be a
> workaround, I would guess.

Ah! A useful feature I was not familiar with. Definitely helps a great deal. Thank you!

← back to recent threads