From: Guo Tingsheng <CoriCraft16@outlook.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: [BUG] git merge sometimes loses changes from one branch
Date: Fri, 12 Sep 2025 13:40:57 +0000 [thread overview]
Message-ID: <SN6PR03MB4285CA9885AE7952EEF762E1AE08A@SN6PR03MB4285.namprd03.prod.outlook.com> (raw)
Hello Git developers,
I would like to report a potential issue in Git's merge behavior, where changes from one branch may be lost even when the other branch does not modify the same location.
Environment:
- git version: 2.43.0
- OS: Ubuntu 24.04 LTS
Steps to reproduce:
1. On branch A, modify a file at a certain location:
@@ -1026,7 +1028,9 @@
public final class AutoBuilderCompilationTest {
" }",
"}");
Compilation compilation =
- javac().withProcessors(new AutoBuilderProcessor()).compile(javaFileObject);
+ javac()
+ .withProcessors(new AutoBuilderProcessor())
+ .compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
.hadErrorContaining(
2. On branch B, make no changes to this location.
3. Merge branch A and branch B.
Expected result:
- The merge should retain the changes made in branch A:
@@ -1026,7 +1028,9 @@
public final class AutoBuilderCompilationTest {
" }",
"}");
Compilation compilation =
- javac().withProcessors(new AutoBuilderProcessor()).compile(javaFileObject);
+ javac()
+ .withProcessors(new AutoBuilderProcessor())
+ .compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
.hadErrorContaining(
Actual result:
- Git sometimes produces a merged result where the modification from branch A is lost, yielding:
@@ -1026,7 +1028,9 @@
public final class AutoBuilderCompilationTest {
" }",
"}");
Compilation compilation =
javac().withProcessors(new AutoBuilderProcessor()).compile(javaFileObject);
assertThat(compilation).failed();
assertThat(compilation)
.hadErrorContaining(
Additional information:
- This issue occurs even when the other branch (B) does not modify the same location.
- It appears to happen non-deterministically and may lead to subtle bugs in real-world merges.
Thanks,
Cori
next reply other threads:[~2025-09-12 13:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 13:40 Guo Tingsheng [this message]
2025-09-12 22:56 ` [BUG] git merge sometimes loses changes from one branch Elijah Newren
2025-10-28 16:12 ` 回复: " Guo Tingsheng
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SN6PR03MB4285CA9885AE7952EEF762E1AE08A@SN6PR03MB4285.namprd03.prod.outlook.com \
--to=coricraft16@outlook.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).