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

Re: Merging submodules

From
SBSanti Béjar <sbejar@gmail.com>
Date
Jul 31, 2008, 15:24 UTC
Message-ID
<8aa486160807310824h25c9630dxc25b156e80fcdb29@mail.gmail.com>
In-Reply-To
<20080731170123.79e0d3e9@pc09.procura.nl>
On Thu, Jul 31, 2008 at 17:01, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
Show 27 quoted lines
> On Thu, 31 Jul 2008 15:06:26 +0200, Petr Baudis <pasky@suse.cz> wrote:
>
>> On Thu, Jul 31, 2008 at 02:39:55PM +0200, H.Merijn Brand wrote:
>> >
>> > There is a slight problem with this merging approach. The path names
>> > are as they are/were in the submodules. In module_a, foo.pl was without
>> > a leading module_a/ path, and now after integration, it still is. Is it
>> > possible to rethink this whole process that integrates/merges the
>> > several git repo's in subfolders into the current folder, as-if they
>> > would have been in this folder in the first place?
>>
>> I would suggest re-reading Santi's suggestions:
>>
>> > You have, basically, two possibilities:
>> >
>> > 1) Add the module_# as submodules:
>> >   http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html
>> >   http://git.or.cz/gitwiki/GitSubmoduleTutorial
>> > 2) Add the submodules as subtrees (as gitk and git-gui in git.git)
>> >   http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
>>
>> I think the latter is specifically what you want.
>
> I got stuck in that process, as the new repo thinks all the files from
> the sub-folders belong to the top-folder: After this process, there are
> a lot of files from subfolder include in the "new" top-level folder.
>

I see all OK. Can you provide a self consistent simple testcase that shows what is wrong?

# prepare the project and the modules mkdir project cd project git init ... mkdir module_a cd module_a git init ... # your script # show what you get and what you expect, for example:

$ git show HEAD: # or something equivalent $ ls $ git status ...

Show 27 quoted lines
> --8<--- git-join.sh
> #!/bin/sh
>
> export MODS
> MODS="include fnc"
> MODS="$MODS i00f000 i99f000"
> MODS="$MODS l00m000 l01f000 l02f000 l03f000 l06f000 l90z000"
> MODS="$MODS rpt"
> MODS="$MODS leerpl mutbev prtabel tabellen zoomen"
>
> echo "Creating merge environment"
> rm -rf new
> mkdir new
> cd new
>
> echo "Recovering original repo's"
> tbz -s -x ../lep4gl-git
>
> echo "Initializing new repo"
> git init
>
> for mod in $MODS ; do
>    echo "Merging $mod ..."
>    git remote add -f B$mod $mod
>    git merge -s ours --no-commit B$mod/master
>    git read-tree --prefix=$mod/ -u B$mod/master
>    git commit -m "Merge $mod as our subdirectory"
>    git pull -s subtree B$mod master

This is only needed when updating the subtree if the module has been updated (but it should do nothing in you case).

>    done
>
> echo Done
> -->8---
Santi
Previous: H.Merijn BrandNext: H.Merijn Brand
Message 6 of 18 in “Re: Merging submodules (was Re: Feature suggestion: git-hist)”
  1. Brian GernhardtJul 30, 2008
  2. H.Merijn BrandJul 31, 2008
  3. H.Merijn BrandJul 31, 2008
  4. Petr BaudisJul 31, 2008
  5. H.Merijn BrandJul 31, 2008
  6. Santi BéjarJul 31, 2008
  7. H.Merijn BrandJul 31, 2008
  8. Santi BéjarJul 31, 2008
  9. H.Merijn BrandJul 31, 2008
  10. H.Merijn BrandAug 1, 2008
  11. Santi BéjarAug 1, 2008
  12. H.Merijn BrandAug 1, 2008
  13. Santi BéjarAug 1, 2008
  14. H.Merijn BrandAug 4, 2008
  15. Petr BaudisAug 4, 2008
  16. H.Merijn BrandAug 4, 2008
  17. Petr BaudisAug 4, 2008
  18. Santi BéjarJul 31, 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.