Re: User's mailing list? And multiple cherry pick
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Jun 4, 2008, 08:50 UTC
- Message-ID
- <200806041050.09701.jnareb@gmail.com>
- In-Reply-To
- <18c1e6480806040111s606701dfwc8a2ae5f742307b5@mail.gmail.com>
On Wed, 4 June 2008, David wrote:
Show 22 quoted lines
> > Thanks, but this doesn't quite solve the problem. I'm on the verge of > figuring it out, and would appreciate any further tips :-) > > Here is an example: > > o--o--O master > \ > o--o--X--X--X--X--o--o topic > > I want to copy the "X" patches from the topic branch over to master. > The other patches aren't appropriate for master for whatever reason. > eg, temporary debugging hacks, but I fixed a few problems in master in > the X patches and now want to apply them on top of master, and keep > working on "topic" > > I want to end up with a tree like this: > > > o--o--O--X'--X'--X'--X' master > \ > o--o--X--X--X--X--o--o topic
I think the simplest solution would be to mark old master, change it to topic (merge or branch -f), and use interactive rebase.
$ git checkout master
$ git branch TMP
o--o--O *master, TMP
\
o--o--X--X--X--X--o--o topicwhere '*master' means that 'master' is current branch.
Then to rewind 'master' to 'topic' you can use either $ git merge topic which should fast-forward to 'topic', or use git-reset $ git reset --hard topic
o--o--O TMP
\
o--o--X--X--X--X--o--o topic, *masterThen there is simply a matter of rebasing master interactively, picking commits marked X.
$ git rebase --interactive TMP # pick commits marked X in above diagram, backup (save) both original # list of commits, and final list of commits.
It is now safe to delete 'TMP' branch
$ git branch -d TMP
o--o--O--X'--X'--X'--X' *master
\
o--o--X--X--X--X--o--o topicNow, if all goes well it would be simply a matter of rebasing 'topic' on top of 'master'; git-rebase would skip commits that are already there.
If it is not the case, use interactive rebase again, this time picking commits marked 'o' (if you saved original series, and list of commits rebased, this should be fairly easy to find/do).
Show 6 quoted lines
> After getting the branches like this, I would then (try to) rebase > topic like this: > > o--o--O--X'--X'--X'--X' master > \ > o'--o'--o'--o' topic
And here you are.
HTH
-- Jakub Narebski Poland