git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How can I merge some files rather than all files modified on one branch to my branch?

From
Boyd Stephen Smith Jr. <bss@iguanasuicide.net>
Date
Mar 3, 2009, 03:10 UTC
Message-ID
<200903022110.23207.bss@iguanasuicide.net>
In-Reply-To
<856bfe0e0903020119y68188a39m90c683949220b2f@mail.gmail.com>
On Monday 02 March 2009 03:19:05 Emily Ren wrote:
> I want to merge some files rather than all files modified on one
> branch to my branch, how can I do?

In addition to what Junio suggested, I'll offer another method, assuming the branch you are merging from is not yet published: (1) Rewrite the history of the to-be-merged branch so that all the changes to the files you want occur "before" and in separate commits from the file you want to ignore. So the current tree:

A-->B-->C (yours)
 \
  ->D-->E (theirs)
becomes:
A-->B-->C (yours)
 \
  ->D1-->E1-->D2-->E2 (theirs)

with D1 and D2 being the separate parts of commit D and similarly for E1 and E2.

(2) Merge in the rewritten history, but only the part that you want, giving:
A-->B-->C--->F (yours)
 \         /
  ->D1-->E1-->D2-->E2 (theirs)

This preserves the full intent of what you are trying to do, a partial merge. If you merge "theirs" in fully at some point in the future, you shouldn't see any conflicts arising from not recording the merge or missing changes arising from recording a full merge that did not happen.

-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/
Previous: Junio C HamanoNext: Emily Ren
Message 3 of 5 in “How can I merge some files rather than all files modified on one branch to my branch?”
  1. Emily RenMar 2, 2009
  2. Junio C HamanoMar 2, 2009
  3. Boyd Stephen Smith Jr.Mar 3, 2009
  4. Emily RenMar 3, 2009
  5. Nicolas SebrechtMar 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.