* Re: Feature that allows the user to merge only specific files/folders from another branch
2026-02-24 13:44 ` Feature that allows the user to merge only specific files/folders from another branch Sugiarto, Titania
@ 2026-02-24 19:21 ` Thomas Guyot
2026-02-24 22:27 ` Junio C Hamano
2026-02-24 22:44 ` Kristoffer Haugsbakk
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Guyot @ 2026-02-24 19:21 UTC (permalink / raw)
To: Sugiarto, Titania, git@vger.kernel.org
On 2026-02-24 08:44, Sugiarto, Titania wrote:
> Hi,
>
> 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.
> 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.
>
> Might be worthwhile to consider?
Hi Titania,
I believe what you are looking for is already easily doable with:
git merge --no-commit
Then you can revert some of the changes you don't want in the index
before running this to complete the merge:
git merge --continue
Note that subsequent merges from that branch would not include the
changes you skipped, that's the core concept of merging and you can't
avoid it. That said you can also cherry-pick specific commits, also with
the same --no-edit flag to allow editing the cherry pick.
Since cherry-picking is centered around individual commits, doing that
for all commits of a forked branch might be difficult. It appears there
a -m/--mainline switch in cherry-pick to allow that but I have never
used it. You will have to experiment yourself if this is what you want.
Regards,
--
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature that allows the user to merge only specific files/folders from another branch
2026-02-24 13:44 ` Feature that allows the user to merge only specific files/folders from another branch Sugiarto, Titania
2026-02-24 19:21 ` Thomas Guyot
@ 2026-02-24 22:27 ` Junio C Hamano
2026-02-24 22:44 ` Kristoffer Haugsbakk
2 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2026-02-24 22:27 UTC (permalink / raw)
To: Sugiarto, Titania; +Cc: git@vger.kernel.org
"Sugiarto, Titania" <titania.sugiarto@rwth-aachen.de> writes:
> 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. 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.
What happens when a branch does three different things, and you
merge that branch to the mainline but taking only changes for one of
these three things? You get changes only to specific files merged,
which is what you seem to be talking about here.
You can do so with "git merge --no-commit", followed by selectively
reverting the working tree changes to the state recorded in HEAD
with either Git tools or your editor, and concluded by "git commit",
but anybody doing so must consider the implications for doing so.
We need to remember that a merge commit is this declaration:
I inspected and understand what this side branch does and what we
have done in the mainline, and came up with this tree state as
the merge result. It is my belief that this result suits the
objective of the project better than either of these two branch
tips I am merging together.
After you made such a declaration on the mainline branch, you made
everbody to agree that among three things the side branch did, two
of them that you did not take were bad idea and should be discarded
(anybody who do not subscribe to that idea can go elsewhere and feel
free to no longer work on the same mainline).
But what happens 3 months after you make such a merge somebody else
(and it could well be you) realize that they want one of the other
two remaining changes out of that same branch? As you have already
made such a one-third merge, they cannot merge the same branch again
to resurrect the two other changes you have already discarded
earlier.
You'd need to find these discarded two other changes _somehow_ if
you need to resurrect them later, but how?
When a bug is reported on such a state after the merge, the author
of that side branch may remember that the bug is addressed by one of
these two changes you did not include in the merge, but if anybody
asks Git "is the branch that supposed to include the bugfix already
merged to the mainline?" they will get "Yes". In other words, they
run "git log mainline..three-things-branch" and they will get an
empty result because you made that one-third merge. The release
manager will scratch their head until they realize what you did,
picking only one of the three things the branch did, but recording
that as a merge with that branch that did three things.
Chaos.
> Might be worthwhile to consider?
So,... not really.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature that allows the user to merge only specific files/folders from another branch
2026-02-24 13:44 ` Feature that allows the user to merge only specific files/folders from another branch Sugiarto, Titania
2026-02-24 19:21 ` Thomas Guyot
2026-02-24 22:27 ` Junio C Hamano
@ 2026-02-24 22:44 ` Kristoffer Haugsbakk
2026-02-25 21:56 ` Junio C Hamano
2 siblings, 1 reply; 5+ messages in thread
From: Kristoffer Haugsbakk @ 2026-02-24 22:44 UTC (permalink / raw)
To: Sugiarto, Titania, git@vger.kernel.org
On Tue, Feb 24, 2026, at 14:44, Sugiarto, Titania wrote:
> Hi,
>
> 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.
> 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.
>
> Might be worthwhile to consider?
Why?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature that allows the user to merge only specific files/folders from another branch
2026-02-24 22:44 ` Kristoffer Haugsbakk
@ 2026-02-25 21:56 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2026-02-25 21:56 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: Sugiarto, Titania, git@vger.kernel.org
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
> On Tue, Feb 24, 2026, at 14:44, Sugiarto, Titania wrote:
>> Hi,
>>
>> 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.
>> 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.
>>
>> Might be worthwhile to consider?
>
> Why?
Because many people talked about it?
Yes, I know that an idea is not necessarily a good one only because
many talk about it ;-)
^ permalink raw reply [flat|nested] 5+ messages in thread