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

directory / submodule merge conflcts

From
MLMark Levedahl <mlevedahl@verizon.net>
Date
Jul 12, 2008, 16:01 UTC
Message-ID
<4878D561.8090009@verizon.net>

Over time, I have converted a number of subdirectories in a main project into submodules, while maintaining the complete pathnames intact. Thus, only git knows that an object at code/dir1 is a submodule or a subdirectory of the superproject.

git has trouble merging branches across the above boundaries, the script below demonstrates the issue. I cannot merge the main branch and a branch that occurred before conversion to a submodule.

Paraphrasing the script, the formula is
    - create a superproject with a subdirectory (sub1)
    - on master, convert sub1 to a submodule (no other changes)
    - on branch base (before sub1 conversion to a submodule), change a 
file not in sub1 (no other changes)
    - merge master into base - failure

The actual reported error message is: fatal: cannot read object b500f4d0c6aaf40a0251da35b82c0fa5c57b6503 'sub1~master': It is a submodule! Merge with strategy recursive failed.

Any ideas or hints on how to improve this would be greatly appreciated.

Thanks, Mark

#!/bin/sh # # demonstrate issue with directory / submodule (D/S) conflict problem

mkdir dsprob || exit cd dsprob git init mkdir sub1 echo hi > foo echo hi1 > sub1/foo git add . git commit -m "Create base" git checkout -b base echo bye >> foo git add . git commit -m "Modify base" git checkout master

# make sub1 a submodule git rm -r -f sub1 git commit -m "removed sub1 directory" git checkout base sub1 git reset cd sub1 git init git add . git commit -m "Start sub1 as its own project" cd .. mv sub1 sub1_repo git submodule add "$(pwd)/sub1_repo" sub1 git commit -m "Added sub1 as a submodule"

# now, go back to base and try to merge rm -rf sub1 git checkout -f base git merge master

Message 1 of 1 in “directory / submodule merge conflcts”
  1. Mark LevedahlJul 12, 2008

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.