From: Jeff King <peff@peff.net>
To: The Git Mailing List <git@vger.kernel.org>
Subject: Re: "git merge" merges too much!
Date: Sun, 29 Nov 2009 00:14:27 -0500 [thread overview]
Message-ID: <20091129051427.GA6104@coredump.intra.peff.net> (raw)
In-Reply-To: <m1NEaLp-000kn1C@most.weird.com>
On Sat, Nov 28, 2009 at 10:21:25PM -0500, Greg A. Woods wrote:
> Hope I've found the right list on which to ask potentially naive
> questions! I've been doing _lots_ of reading about Git, but I can't
> seem to find anything about the problems I relate below.
Yep, you're in the right place.
> master branch to represent release points -- is there any way to get
> "git log" to show which tags are associated with a given commit and/or
Try "git log --decorate".
> BL1.2 - A - B - C <- BL1.2 HEAD
> /
> master 1 - 2 - TR1.1 - 3 - 4 - 5 - TR1.2 <- master HEAD
>
> [...]
>
> git checkout -b BL1.1 TR1.1
> git merge BL1.2
>
> However this seems to merge all of 3, 4, and 5, as well as A, B, and C.
>
> I think I can (barely) understand why it's doing what it's doing, but
> that's not what I want it to do. However it looks like Git doesn't have
> the same idea of a branch "base" point as I think I do.
Yes. Git doesn't really view history as branches in the way you are
thinking. History is simply a directed graph, and when you merge two
nodes in the graph, it takes into account _everything_ that happened
to reach those two points since the last time they diverged (which in
your case is simply TR1.1, as BL1.2 is a strict superset).
There is no way in the history graph to represent "we have these
commits, but not this subsequence". You have to create new commits A',
B', and C' which introduce more or less the same changes as their
counterparts (and they may even be _exactly_ the same except for the
parentage, but then again, they may not if the changes they make do not
apply in the same way on top of TR1.1).
> Running "git log TR1.2..BL1.2" does show me exactly the changes I wish
> to propagate, but "git merge TR1.2..BL1.2" says "not something we can
> merge". Sigh.
>
> How can I get it to merge just the changes from the "base" of the BL1.2
> branch to its head?
>
> Is using either git-cherry-pick or "git log -p | git-am", the only way
> to do this? Which way best preserves Git's ability to realize if a
> change has already been included on the target branch, if any?
Yes, you must cherry-pick or use rebase (which is a more featureful
version of the pipeline you mentioned). Either way will produce an
equivalent set of commits (cherry-pick is useful when you are picking a
couple of commits; rebase is useful for rewriting a whole stretch of
history. It sounds like you want to do the latter).
The resulting commits will have different commit ids, but git generally
does a good job at merging such things, because it looks only at the
result state and not the intermediate commits. If both sides have made
an equivalent change, then there is no conflict.
> Is there any way to get "git log --graph" (and/or gitk) to show me all
> the branch heads, not just the current/specified one?
Try "--all" with either gitk or "git log". Or if you want a subset of
heads, just name them.
Hope that helps,
-Peff
next prev parent reply other threads:[~2009-11-29 5:14 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-29 3:21 "git merge" merges too much! Greg A. Woods
2009-11-29 5:14 ` Jeff King [this message]
2009-11-30 18:12 ` Greg A. Woods
2009-11-30 19:22 ` Dmitry Potapov
2009-12-01 18:52 ` Greg A. Woods
2009-12-01 20:50 ` Dmitry Potapov
2009-12-01 21:58 ` Greg A. Woods
2009-12-02 0:22 ` Dmitry Potapov
2009-12-02 10:20 ` Nanako Shiraishi
2009-12-02 20:09 ` Jeff King
2009-12-03 1:21 ` Git documentation consistency (was: "git merge" merges too much!) Greg A. Woods
2009-12-03 1:34 ` Git documentation consistency Junio C Hamano
2009-12-03 7:22 ` Greg A. Woods
2009-12-03 7:45 ` Jeff King
2009-12-03 15:24 ` Uri Okrent
2009-12-03 16:22 ` Marko Kreen
2009-12-09 19:56 ` Greg A. Woods
2009-12-03 2:07 ` Git documentation consistency (was: "git merge" merges too much!) Jeff King
2009-11-29 5:15 ` "git merge" merges too much! Junio C Hamano
2009-11-30 18:40 ` Greg A. Woods
2009-11-30 20:50 ` Junio C Hamano
2009-11-30 21:17 ` Dmitry Potapov
2009-12-01 0:24 ` Greg A. Woods
2009-12-01 5:47 ` Dmitry Potapov
2009-12-01 17:59 ` multiple working directories for long-running builds (was: "git merge" merges too much!) Greg A. Woods
2009-12-01 18:51 ` Dmitry Potapov
2009-12-01 18:58 ` Greg A. Woods
2009-12-01 21:18 ` Dmitry Potapov
2009-12-01 22:25 ` Jeff Epler
2009-12-01 22:44 ` Greg A. Woods
2009-12-02 0:10 ` Dmitry Potapov
2009-12-03 5:11 ` Greg A. Woods
2009-12-02 2:09 ` multiple working directories for long-running builds Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091129051427.GA6104@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).