From: Junio C Hamano <gitster@pobox.com>
To: "Sugiarto, Titania" <titania.sugiarto@rwth-aachen.de>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Feature that allows the user to merge only specific files/folders from another branch
Date: Tue, 24 Feb 2026 14:27:47 -0800 [thread overview]
Message-ID: <xmqqa4wxepzw.fsf@gitster.g> (raw)
In-Reply-To: <14775be9ed944bf684c3696e1a10f44d@rwth-aachen.de> (Titania Sugiarto's message of "Tue, 24 Feb 2026 13:44:26 +0000")
"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.
next prev parent reply other threads:[~2026-02-24 22:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <532e9d58b905404fa625aa59104ce8f5@rwth-aachen.de>
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 [this message]
2026-02-24 22:44 ` Kristoffer Haugsbakk
2026-02-25 21:56 ` Junio C Hamano
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=xmqqa4wxepzw.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=titania.sugiarto@rwth-aachen.de \
/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