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

[BUG?] Issue with merging from another branch after replacing subdirectory with submodule

From
BNBen Nason <bnason@netflix.com>
Date
Apr 6, 2017, 06:10 UTC
Message-ID
<CAA-fqg2EwfMQ-KoAMHDFca1c7jpQgihhqsLejEK3Zs8O1D4DLg@mail.gmail.com>
Hi,

In git if you replace a subdirectory with a submodule in one branch, every successive merge from another branch without that change will cause a conflict. To reproduce this please see below (DOS batch file).

Is this expected behavior?

Thanks, Benbuck

:: prep simple repo with subdir git init repo pushd repo echo foo > foo.txt git add --all git commit -m "foo" mkdir sub echo bar > sub\bar.txt git add --all git commit -m "bar" popd

:: prep simple submodule git init submod pushd submod echo baz2 > baz.txt git add --all git commit -m "baz2" popd

:: in a new branch: delete subdir, replace with submodule pushd repo git checkout -b resub git rm -rf sub git commit -m "delete subdir" git submodule add ../submod sub git submodule update --init git commit -m "add submod"

:: in old branch: make an unrelated change git checkout master git clean -fd git rs --hard master echo foo2 > foo.txt git commit --all -m "foo2"

:: switch back to new branch git checkout resub git rs --hard resub git submodule update --init pushd sub git reset --hard master popd

:: all is good so far, now merge git merge master git status @echo !!!!!! note the above merge conflict !!!!!! pause :: resolve the conflict to keep the submodule git reset sub git commit --no-edit

:: make another change to old branch git checkout master git clean -fd git rs --hard master echo foo3 > foo.txt git commit --all -m "foo3" git checkout resub git rs --hard resub git submodule update --init pushd sub git reset --hard master popd

:: merge again git merge master git status @echo !!!!!! note that the conflict happens on every single merge !!!!!! pause

popd
Next: Stefan Beller
Message 1 of 3 in “[BUG?] Issue with merging from another branch after replacing subdirectory with submodule”
  1. Ben NasonApr 6, 2017
  2. Stefan BellerApr 6, 2017
  3. Ben NasonApr 7, 2017

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.