{"thread":{"id":"65069","subject":"Feature that allows the user to merge only specific files/folders from another branch","startedAt":"2026-02-24T13:44:28Z","lastAt":"2026-02-25T21:56:09Z","messageCount":5,"participants":["Sugiarto, Titania","Thomas Guyot","Junio C Hamano","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"536973","messageId":"14775be9ed944bf684c3696e1a10f44d@rwth-aachen.de","threadId":"65069","inReplyTo":"532e9d58b905404fa625aa59104ce8f5@rwth-aachen.de","subject":"Feature that allows the user to merge only specific files/folders from another branch","fromName":"Sugiarto, Titania","fromEmail":"titania.sugiarto@rwth-aachen.de","sentAt":"2026-02-24T13:44:26Z","receivedAt":"2026-02-24T13:44:28Z","isPatch":false,"sender":{"key":"titania.sugiarto@rwth-aachen.de","avatar":null},"body":"Hi, \n\nI have a suggestion for Git, which includes a feature that allows the user to merge (I want to highlight merge here, not replace) specific files/folders from another branch.\nI feel like a lot of users have spoken about this online but up until now, there hasn't been an update regarding such feature.\n\nMight be worthwhile to consider?\n\n\n\n\n\n       "},{"id":"537011","messageId":"3f744aaa-23fd-45f7-9776-87036ec8ffc0@gmail.com","threadId":"65069","inReplyTo":"14775be9ed944bf684c3696e1a10f44d@rwth-aachen.de","subject":"Re: Feature that allows the user to merge only specific files/folders from another branch","fromName":"Thomas Guyot","fromEmail":"tguyot@gmail.com","sentAt":"2026-02-24T19:21:28Z","receivedAt":"2026-02-24T19:21:33Z","isPatch":false,"sender":{"key":"tguyot@gmail.com","avatar":"https://avatars.githubusercontent.com/u/403890?v=4"},"body":"On 2026-02-24 08:44, Sugiarto, Titania wrote:\n> Hi,\n> \n> I have a suggestion for Git, which includes a feature that allows the user to merge (I want to highlight merge here, not replace) specific files/folders from another branch.\n> I feel like a lot of users have spoken about this online but up until now, there hasn't been an update regarding such feature.\n> \n> Might be worthwhile to consider?\n\nHi Titania,\n\nI believe what you are looking for is already easily doable with:\n\n   git merge --no-commit\n\nThen you can revert some of the changes you don't want in the index \nbefore running this to complete the merge:\n\n   git merge --continue\n\nNote that subsequent merges from that branch would not include the \nchanges you skipped, that's the core concept of merging and you can't \navoid it. That said you can also cherry-pick specific commits, also with \nthe same --no-edit flag to allow editing the cherry pick.\n\nSince cherry-picking is centered around individual commits, doing that \nfor all commits of a forked branch might be difficult. It appears there \na -m/--mainline switch in cherry-pick to allow that but I have never \nused it. You will have to experiment yourself if this is what you want.\n\nRegards,\n\n--\nThomas\n\n"},{"id":"537033","messageId":"xmqqa4wxepzw.fsf@gitster.g","threadId":"65069","inReplyTo":"14775be9ed944bf684c3696e1a10f44d@rwth-aachen.de","subject":"Re: Feature that allows the user to merge only specific files/folders from another branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-24T22:27:47Z","receivedAt":"2026-02-24T22:27:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sugiarto, Titania\" <titania.sugiarto@rwth-aachen.de> writes:\n\n> I have a suggestion for Git, which includes a feature that allows\n> the user to merge (I want to highlight merge here, not replace)\n> specific files/folders from another branch.  I feel like a lot of\n> users have spoken about this online but up until now, there hasn't\n> been an update regarding such feature.\n\nWhat happens when a branch does three different things, and you\nmerge that branch to the mainline but taking only changes for one of\nthese three things?  You get changes only to specific files merged,\nwhich is what you seem to be talking about here.\n\nYou can do so with \"git merge --no-commit\", followed by selectively\nreverting the working tree changes to the state recorded in HEAD\nwith either Git tools or your editor, and concluded by \"git commit\",\nbut anybody doing so must consider the implications for doing so.\n\nWe need to remember that a merge commit is this declaration:\n\n   I inspected and understand what this side branch does and what we\n   have done in the mainline, and came up with this tree state as\n   the merge result.  It is my belief that this result suits the\n   objective of the project better than either of these two branch\n   tips I am merging together.\n\nAfter you made such a declaration on the mainline branch, you made\neverbody to agree that among three things the side branch did, two\nof them that you did not take were bad idea and should be discarded\n(anybody who do not subscribe to that idea can go elsewhere and feel\nfree to no longer work on the same mainline).\n\nBut what happens 3 months after you make such a merge somebody else\n(and it could well be you) realize that they want one of the other\ntwo remaining changes out of that same branch?  As you have already\nmade such a one-third merge, they cannot merge the same branch again\nto resurrect the two other changes you have already discarded\nearlier.\n\nYou'd need to find these discarded two other changes _somehow_ if\nyou need to resurrect them later, but how?\n\nWhen a bug is reported on such a state after the merge, the author\nof that side branch may remember that the bug is addressed by one of\nthese two changes you did not include in the merge, but if anybody\nasks Git \"is the branch that supposed to include the bugfix already\nmerged to the mainline?\" they will get \"Yes\".  In other words, they\nrun \"git log mainline..three-things-branch\" and they will get an\nempty result because you made that one-third merge.  The release\nmanager will scratch their head until they realize what you did,\npicking only one of the three things the branch did, but recording\nthat as a merge with that branch that did three things.\n\nChaos.\n\n> Might be worthwhile to consider?\n\nSo,... not really.\n\n"},{"id":"537037","messageId":"b743b7fe-5f5a-4906-9ea6-0755acf5875d@app.fastmail.com","threadId":"65069","inReplyTo":"14775be9ed944bf684c3696e1a10f44d@rwth-aachen.de","subject":"Re: Feature that allows the user to merge only specific files/folders from another branch","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-02-24T22:44:31Z","receivedAt":"2026-02-24T22:44:53Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Tue, Feb 24, 2026, at 14:44, Sugiarto, Titania wrote:\n> Hi,\n>\n> I have a suggestion for Git, which includes a feature that allows the\n> user to merge (I want to highlight merge here, not replace) specific\n> files/folders from another branch.\n> I feel like a lot of users have spoken about this online but up until\n> now, there hasn't been an update regarding such feature.\n>\n> Might be worthwhile to consider?\n\nWhy?\n"},{"id":"537157","messageId":"xmqq1pi88p3c.fsf@gitster.g","threadId":"65069","inReplyTo":"b743b7fe-5f5a-4906-9ea6-0755acf5875d@app.fastmail.com","subject":"Re: Feature that allows the user to merge only specific files/folders from another branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-25T21:56:07Z","receivedAt":"2026-02-25T21:56:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\n\n> On Tue, Feb 24, 2026, at 14:44, Sugiarto, Titania wrote:\n>> Hi,\n>>\n>> I have a suggestion for Git, which includes a feature that allows the\n>> user to merge (I want to highlight merge here, not replace) specific\n>> files/folders from another branch.\n>> I feel like a lot of users have spoken about this online but up until\n>> now, there hasn't been an update regarding such feature.\n>>\n>> Might be worthwhile to consider?\n>\n> Why?\n\nBecause many people talked about it?\n\n\n\n\n\n\n\n\n\n\n\n\nYes, I know that an idea is not necessarily a good one only because\nmany talk about it ;-)\n"}]}