hraban / tomono

Multi- To Mono-repository merge
https://tomono.0brg.net
GNU Affero General Public License v3.0
842 stars 138 forks source link

Create monorepo with git commit history without branches #27

Closed Lomiren closed 4 years ago

Lomiren commented 6 years ago

Hi.

Could you add the ability to create a clean new repository where the commit history of several projects is preserved, but the old branches are not migrated. I want to combine several of my projects which are already several years in one monorepository to get something like this: . core/ . . projects/ . . . project1 (use devPod1,devPod2,devPod3...) . . . project2 (use devPod1,devPod2,devPod3...) . . . projetct3 (use devPod1, devPod3...) . . developerPods . . . devPod1 . . . devPod2 . . . devPod3

hraban commented 6 years ago

Hi lomiren,

Only master branch

Is it possible for you to remove the old branches before you use tomono script? Alternatively, this is a bit cheeky but it would work: since branches are copied to the same name in the final monorepo, you could do a full migration and later remove all the branches on the final repo :)

Like this:

... tomono.sh
cd core
git checkout master
git branch | grep -v '^\*' | xargs git branch -D

This would leave you with just the master branch.

Developer pods

I'm not sure I understand this bit; what are developer pods? Are they just git repositories like the main projects? Then you can use a / in the directory name to put them in that subdirectory. See the README for further info, but essentially your repos.txt would look like this:

git@github.com:Lomiren/project1.git project1 projects/project1
git@github.com:Lomiren/project2.git project2 projects/project2
git@github.com:Lomiren/devPod1.git devPod1 developerPods/devPod1
git@github.com:Lomiren/devPod2.git devPod2 developerPods/devPod2

Hope this helps. Good luck!

Lomiren commented 6 years ago

Developer pods Yes. They are just git repositories. And my repos.txt look like in documentation, it's all right.

Only Master. No I can't delete branches before use tomono. Other developers use it while i try to crate monorepo :) I try to use git checkout master git branch | grep -v '^*' | xargs git branch -D

Local branches was deleted. But they stay in remote.

I just want get new monerepo with "master" branch without copy old branches

hraban commented 6 years ago

to delete them in remote, use git branch | grep -v '^*' | xargs git push --delete origin before the last line (after creating a fresh monorepo). This is by far the simplest solution because it doesn't require any code change and you only need to do it once. Then do the last line to delete them locally, as well.

hraban commented 6 years ago

Although, come to think of it; why do they live on remote in the first place? the tomono script doesn't create an origin remote for you, so where are these branches coming from?