Git development
 help / color / mirror / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: "fkater@googlemail.com" <fkater@googlemail.com>
Cc: <git@vger.kernel.org>
Subject: Re: merge only some of the changed files?
Date: Fri, 19 Mar 2010 15:01:57 +0100	[thread overview]
Message-ID: <201003191501.58045.trast@student.ethz.ch> (raw)
In-Reply-To: <20100319134028.GA2318@comppasch2>

fkater@googlemail.com wrote:
> If I want to merge branch B into A, however not all of the
> changed files in B, how do I do that?
> 
> In other words: 'git diff --name-only A..B' lists 10 files
> but I want to merge only 5 of them.

First of all, these are not the differences that would be merged: if
you're on A and run 'git merge B', it will merge the changes since the
merge-base(s) of A and B.  Assuming you only have a single merge-base,
this is

  git diff $(git merge-base A B) B

which you can write more conveniently (see man git-diff) as

  git diff A...B

(note the three dots!).

Second, you can't really do a "half merge" because that would be a
lie.  A merge promises to bring all changes from all parents, which
you don't want to do.  You can either split out the relevant changes
from your branch (use e.g. git-cherry-pick or 'git rebase -i' on a new
branch B1 started from B) on the branch, and merge that.  Or you can
do a "squashed merge" of only the files you want by saying e.g.

  git diff A...B -- file1 file2 | git apply

and then committing that with a suitable message.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

      parent reply	other threads:[~2010-03-19 14:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19 13:40 merge only some of the changed files? fkater
2010-03-19 13:55 ` Michael J Gruber
2010-03-19 14:01 ` Thomas Rast [this message]

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=201003191501.58045.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=fkater@googlemail.com \
    --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