Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Anyone have resources on how to actually perform the migration of many repos to monorepo? Currently facing the same issue and want to make the consolidation move but now sure on how to merge the git history. This article and the previous one it links to are missing all the implementation details.


It takes a bit of time. You’d want to do it one by one. I’ve done it the other way (mono repo code to library) and it’s worth the time to keep the history around where you are working. I just did a google search. First one that comes up tonight is this article: https://medium.com/@ayushya/move-directory-from-one-reposito...


Don’t, keep things simple. Maintain a separate archive of each individual repository and any history can be referenced in that repository when necessary.


I just finished a migration like that, and after some research ended up writing shell code to implement 3 methods and put them to the test. Maybe it is useful for you so I'll leave it here:

https://gist.github.com/j1elo/6156437f26bfc580769613bb30419a...

My first step was to learn the procedure that devs behind GStreamer used recently, when they went ahead and decided to merge all their disparate repos into a single monorepo. For my needs it is the less adequate of the three because it will break as soon as there is any collision between the desired destination and the already existing files of a repo.

The second method is one proposed in the JDriven blog. It doesn't suffer collisions because the movement into destination subdir of each repo is done separately on the original repos, and then they are merged with everything already in place.

Lastly, I found a third method which is the one I liked the most. It uses git subtrees, to perform the move and merge all in the target repo (the monorepo itself), without touching the original repos (unlike the JDriven proposal), so everything is tidy and left in place.

Method 1 (GStreamer):

* https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/...

* https://blogs.gnome.org/tsaunier/2021/09/29/gstreamer-one-re...

* https://gitlab.freedesktop.org/thiblahute/gst-merger/blob/ma...

Method 2 (JDriven):

* https://blog.jdriven.com/2021/04/how-to-merge-multiple-git-r...

Method 3 (Subtrees):

* https://mirrors.edge.kernel.org/pub/software/scm/git/docs/ho...

* https://docs.github.com/en/get-started/using-git/about-git-s...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: