I'm using Git on GNU/Linux.

I need to backport a discrete set of commits to an older release branch.
Because this is an older branch I definitely do not want to merge: I
need to either rebase or cherry-pick or whatever.

Rebase doesn't seem to be an option, because the set of commits aren't
on their own branch and rebase doesn't appear to allow specifying a
specific list of commits to rebase.  I could use rebase -i, but the
branches have diverged so far that there are hundreds of commits I'd
have to skip just to the the 8 or so I want to keep.  Too annoying.

So I was going to use cherry-pick but ran into two problems:

The first one is that I wanted to cherry-pick a range, plus a straggler,
so I did this which appears from the man page to be what I want
(obviously my real command uses SHAs):

   git cherry-pick A^..F J

The intent is to skip commits G, H, and I.  However, this does not work;
it attempts to cherry pick ALL the commits in the range A..J, including
G, H, and I.

Is this a bug in Git, or am I misunderstanding something?

So then I decided to list the commots one at a time on the command line
rather than use the range.  These commits are all a flailing attempt to
fix a problem (unfortunately in order to get these changes into our test
system they had to be pushed so this flailing is now public *sigh*) so I
thought I would like to use the "-n" flag with cherry-pick to do a kind
of "merge --squash" and combine all the flailing into one commit.

However, the very first cherry-pick had a conflict I needed to resolve,
so I did resolve it.  Normally one would then "git add" and "git
cherry-pick --continue" but doing so with -n gives an error:

   error: Your local changes would be overwritten by cherry-pick.
   hint: Commit your changes or stash them to proceed.
   fatal: cherry-pick failed

If I try NOT "git add"ing the change before running --continue then I

   error: Your local changes to the following files would be overwritten by 
   Please, commit your changes or stash them before you can merge.

So, am I missing something or is "git cherry-pick -n" just not usable in
any situation where you might have a conflict that needs to be resolved?

I'm going to create a temporary branch and run the cherry-pick there
(without -n), then do a merge --squash, which I expect will work.  But I
wonder if the above are bugs I should report, or misunderstandings on my
part, or simply expecting too much of the tool.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to