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

Re: git bug: Including a git repository in a directory

From
René Scharfe <l.s.r@web.de>
Date
Jun 6, 2022, 11:00 UTC
Message-ID
<24022c08-ed58-8157-6036-6a4c6a49f195@web.de>
In-Reply-To
<e308be58-a399-8e5c-36a8-96d3d58caff3@sprangle.com>
Am 06.06.22 um 07:43 schrieb Steven Jonn Edlefsen:
Show 17 quoted lines
> Git cannot commit/push a directory with a git repository in
> a sub-directory.
>
> The sub-directory with the git repository and the directories below
> are set to the “master” branch, while the directories above remain
> set to the new branch.
>
> When the top directory is committed, the sub-directory with the
> git repository appears as an empty file.
>
> Even when the subdirectory branch name is changed from master
> to the new branch and the top directory is re-commited/pushed,
> the same problem occurs.
>
> When the git repository in the sub-directory is removed, e.g.
> the .git file is removed, and top directory is committed/pushed,
> the subdirectory has all the sub-directories and files.

This is intended behavior. A repository inside another one needs special handling. Git provides the submodule feature for that. A simpler alternative for some use cases is called subtree.

That's all I can tell you, as I haven't used submodules and subtrees myself. At least I hope these keywords help you explore your options. Others will probably chime in with advise on which one to use if you explain _why_ you want to combine multiple repositories.

René
Previous: Steven Jonn EdlefsenNext: Glen Choo
Message 2 of 3 in “git bug: Including a git repository in a directory”
  1. Steven Jonn EdlefsenJun 6, 2022
  2. René ScharfeJun 6, 2022
  3. Glen ChooJun 6, 2022

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.