git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Thoughts about the -m option of cherry-pick and revert
@ 2024-06-20 10:05 Stefan Haller
  2024-06-21  2:03 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Haller @ 2024-06-20 10:05 UTC (permalink / raw)
  To: Git

There are plenty of StackOverflow questions and blog posts about the
error message that you get when you use git cherry-pick or git revert on
a merge commit without specifying the -m option. Many people don't seem
to understand what the error message means, or why they even get an
error in the first place.

The answers to these questions patiently explain what the error means
and why the -m option is necessary. Many of them contain example
scenarios; but I haven't seen a single one that doesn't use -m1 to
illustrate the usage.

I have two questions:

- What are real-world scenarios where you would use a mainline number
  other than 1? I could only come up with a single example myself, which
  is that you have a topic branch, and right before merging it back to
  main, you merge main into the topic branch; and then you merge it to
  main with a fast-forward merge. If you then want to cherry-pick or
  revert that topic, you'd have to use -m2 on that last merge from main.
  Any other examples?
- Wouldn't it make sense to default to -m1 when no -m option is given?
  It seems that this would do the expected thing in the vast majority of
  cases.

For the GUI client that I'm co-maintaining (lazygit), I'm actually
considering going so far as to not providing a choice at all, and always
using -m1. I'm not fully decided yet if that's a good idea, but it seems
that most people expect this, most of the time.

I'm probably missing something though, but what?

-Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-06-24 18:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-20 10:05 Thoughts about the -m option of cherry-pick and revert Stefan Haller
2024-06-21  2:03 ` Junio C Hamano
2024-06-21  6:33   ` Stefan Haller
2024-06-21 10:19     ` Phillip Wood
2024-06-21 11:48       ` Stefan Haller
2024-06-21 16:34       ` Junio C Hamano
2024-06-24  7:33         ` Stefan Haller
2024-06-24 18:43           ` Junio C Hamano
2024-06-21 10:12   ` Phillip Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).