All of lore.kernel.org
 help / color / mirror / Atom feed
* How to integrate external repo into existing directory of a bigger repo (git subtree)?
@ 2020-12-24 14:53 Manuel Reimer
  2020-12-25 10:12 ` Manuel Reimer
  0 siblings, 1 reply; 2+ messages in thread
From: Manuel Reimer @ 2020-12-24 14:53 UTC (permalink / raw)
  To: git

Hello,

some while ago (before I found out that "git subtree" exists), I've set 
up a big GIT repo consisting of several smaller modules. It was way more 
convenient to maintain them all in one repository compared to having 
each in its own repository.

As I need a separate repository per module for technical reasons, I 
wrote a shellscript which temporarily checks out the external 
repository, deletes all files, places the files from my big repo, 
creates a generic commit with auto-generated commit message and then 
pushes this to the server.

So what I have now is:

- Big repo consisting of many small modules, each one in its own
   directory with proper commit messages
- Several external repositories with autogenerated commit messages

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)

Is there any chance to somehow "restart" the history of an existing 
directory in a way to reproduce the commits of the external repository 
so "git subtree" works as intended and I can "git subtree push" without 
running into the server side "force push" block? I know that 
reorganizing my whole big repo would do the trick as the subtree would 
be added to a directory that never existed, but I would prefer to keep 
it organized the way it is.

Thanks in advance

Manuel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to integrate external repo into existing directory of a bigger repo (git subtree)?
  2020-12-24 14:53 How to integrate external repo into existing directory of a bigger repo (git subtree)? Manuel Reimer
@ 2020-12-25 10:12 ` Manuel Reimer
  0 siblings, 0 replies; 2+ messages in thread
From: Manuel Reimer @ 2020-12-25 10:12 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-25 10:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-24 14:53 How to integrate external repo into existing directory of a bigger repo (git subtree)? Manuel Reimer
2020-12-25 10:12 ` Manuel Reimer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.