git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to merge in different order?
@ 2009-04-03 16:12 Josef Wolf
  2009-04-03 16:30 ` Peter Harris
  2009-04-03 16:31 ` Jeff King
  0 siblings, 2 replies; 4+ messages in thread
From: Josef Wolf @ 2009-04-03 16:12 UTC (permalink / raw)
  To: git

Hello,

Given a branch that looks like

  A1  A2  A3  A4  A5

I would like to merge into another branch in the order

  A1  A3  A4  A2  A5

When I merge A3, then A2 is merged also.  git-merge don't seem
to have an option to omit slurping older commits?

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

* Re: How to merge in different order?
  2009-04-03 16:12 How to merge in different order? Josef Wolf
@ 2009-04-03 16:30 ` Peter Harris
  2009-04-03 16:31 ` Jeff King
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Harris @ 2009-04-03 16:30 UTC (permalink / raw)
  To: Josef Wolf, git

On Fri, Apr 3, 2009 at 12:12 PM, Josef Wolf wrote:
> Hello,
>
> Given a branch that looks like
>
>  A1  A2  A3  A4  A5
>
> I would like to merge into another branch in the order
>
>  A1  A3  A4  A2  A5
>
> When I merge A3, then A2 is merged also.  git-merge don't seem
> to have an option to omit slurping older commits?

"git merge" merges the entire branch. It sounds like you are looking
for "git cherry-pick" instead.

Alternatively, you could run "git rebase -i A1" on the branch before
merging it. (See the docs for details)

Peter Harris

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

* Re: How to merge in different order?
  2009-04-03 16:12 How to merge in different order? Josef Wolf
  2009-04-03 16:30 ` Peter Harris
@ 2009-04-03 16:31 ` Jeff King
  2009-04-03 17:59   ` Josef Wolf
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff King @ 2009-04-03 16:31 UTC (permalink / raw)
  To: Josef Wolf, git

On Fri, Apr 03, 2009 at 06:12:08PM +0200, Josef Wolf wrote:

> Given a branch that looks like
> 
>   A1  A2  A3  A4  A5
> 
> I would like to merge into another branch in the order
> 
>   A1  A3  A4  A2  A5
> 
> When I merge A3, then A2 is merged also.  git-merge don't seem
> to have an option to omit slurping older commits?

Right. Remember that git represents history as a directed graph, so a
merge is really just another commit saying "I include all history
leading up to these two commits". There is no way to say "I include the
history leading up to these commits, minus some other commits".

If you just want to throw away A2, you can "git revert" it, then merge.

But what you probably want to do is rewrite the history of your branch
to re-order the commits. You can do this with "git rebase -i". Like any
history rewriting, this can cause difficulties for people who you have
already shared the branch with (because it will replace the commits that
they already have with 5 _new_ commits that just happen to do more or
less the same thing).

If you have already shared the branch, you may just want to cherry-pick
the changes you want (using "git cherry-pick") onto your other branch.

-Peff

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

* Re: How to merge in different order?
  2009-04-03 16:31 ` Jeff King
@ 2009-04-03 17:59   ` Josef Wolf
  0 siblings, 0 replies; 4+ messages in thread
From: Josef Wolf @ 2009-04-03 17:59 UTC (permalink / raw)
  To: git

On Fri, Apr 03, 2009 at 12:31:50PM -0400, Jeff King wrote:

[ ... ]
> But what you probably want to do is rewrite the history of your branch
> to re-order the commits.

Yeah, That's exactly what I need. But I guess there's a lot of work ahead:
about 2500 commits are waiting for the sort.

> You can do this with "git rebase -i".

Sounds good

> Like any
> history rewriting, this can cause difficulties for people who you have
> already shared the branch with (because it will replace the commits that
> they already have with 5 _new_ commits that just happen to do more or
> less the same thing).

This is a copy of a svn repository, created with git-svn. So the branch
is shared with other people.

> If you have already shared the branch, you may just want to cherry-pick
> the changes you want (using "git cherry-pick") onto your other branch.

Argh, I was looking for git-cherry, but that does something different ;-)

Thanks for the answer, Jeff!

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

end of thread, other threads:[~2009-04-03 18:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-03 16:12 How to merge in different order? Josef Wolf
2009-04-03 16:30 ` Peter Harris
2009-04-03 16:31 ` Jeff King
2009-04-03 17:59   ` Josef Wolf

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).