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

Re: How to integrate external repo into existing directory of a bigger repo (git subtree)?

From
MRManuel Reimer <mail+git@m-reimer.de>
Date
Dec 25, 2020, 10:12 UTC
Message-ID
<31b0d4a2-249f-ec18-8b7c-24b4a6165e7b@m-reimer.de>
In-Reply-To
<e30c1de9-9449-78d6-99eb-c3bbad673903@m-reimer.de>
On 24.12.20 15:53, Manuel Reimer wrote:
> What I want to do is porting this over to "git subtree" somehow, but:
> 
> - I would prefer to not loose history in the "big repo"
> - I can't force-push to the small external repositories (blocked)
Just for the record: I found a way to fix this properly.
The way to go is:
- Create a new, empty, GIT repository (git init)
- For some reason (bug?) "git subtree" fails on a completely new repo, 
so I had to add one initial commit (I used this to add a small helper 
shellscript that I want to use to simplify my "git subtree" work).
- Now add all the wanted "git subtrees" from their existing "external 
repositories" to the, so far, nearly empty repo. This creates a proper 
"Add ..." commit which seems to be the key to not break pushing to the 
external repo.
- After adding all subtrees, pull from the "big repo", resolve conflicts 
and create a merge commit.

At this point I was able to "git subtree push" without needing to force. This also transferred proper history for the subtrees to the individual external repos. Even the final push to my "big repo" worked without forcing.

Regards,
Manuel
Previous: Manuel Reimer
Message 2 of 2 in “How to integrate external repo into existing directory of a bigger repo (git subtree)?”
  1. Manuel ReimerDec 24, 2020
  2. Manuel ReimerDec 25, 2020

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.