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

[BUG] git merge sometimes loses changes from one branch

From
GTGuo Tingsheng <coricraft16@outlook.com>
Date
Sep 12, 2025, 13:40 UTC
Message-ID
<SN6PR03MB4285CA9885AE7952EEF762E1AE08A@SN6PR03MB4285.namprd03.prod.outlook.com>
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: Elijah Newren
Message 1 of 3 in “[BUG] git merge sometimes loses changes from one branch”
  1. Guo TingshengSep 12, 2025
  2. Elijah NewrenSep 12, 2025
  3. 回复: [BUG] git merge sometimes loses changes from one branchGuo Tingsheng, Oct 28, 2025

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.