All of lore.kernel.org
 help / color / mirror / Atom feed
* merge only some of the changed files?
@ 2010-03-19 13:40 fkater
  2010-03-19 13:55 ` Michael J Gruber
  2010-03-19 14:01 ` Thomas Rast
  0 siblings, 2 replies; 3+ messages in thread
From: fkater @ 2010-03-19 13:40 UTC (permalink / raw)
  To: git

Hi all,

I am quite new to git.

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.

Thank You
 Felix

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

* Re: merge only some of the changed files?
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Michael J Gruber @ 2010-03-19 13:55 UTC (permalink / raw)
  To: Git Mailing List; +Cc: fkater

fkater@googlemail.com venit, vidit, dixit 19.03.2010 14:40:
> Hi all,
> 
> I am quite new to git.
> 
> 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.

If you are sure you don't want to merge the changes to them later on,
you can do the following while on branch A

# perform the merge but do not commit
git merge --no-commit B
# overwrite the files you want to keep with their version from A
git checkout HEAD -- file1 file2
# commit the merge result
git commit

Cheers,
Michael

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

* Re: merge only some of the changed files?
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Rast @ 2010-03-19 14:01 UTC (permalink / raw)
  To: fkater@googlemail.com; +Cc: git

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

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

end of thread, other threads:[~2010-03-19 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.