Split git into a separate repo

I have the following git tree:

branch v2 => / --- [lots of work] --- [new version] --- ref_d / root --- ref_a --- ... --- ref_b (project reset) \ branch v1 => \ --- [some works] --- ref_c 

Since v1 and v2 are really different, two different teams will support v1 and v2, I would like two separate branches two in different git repositories:

 repo_v1 : from root to ref_c repo_v2 : from ref_b to ref_d 

How can I do it? Thanks.

+10
source share
2 answers

It is further assumed that you have two different new repositories configured as a remote control named repo_v1 and repo_v2 .

Branch v1 is simple:

 git push repo_v1 ref_c:v1 

In the v2 branch, itโ€™s not so difficult:

 git checkout --orphan v2 ref_b git cherry-pick ref_b..ref_d git push repo_v2 v2 

( git checkout --orphan <branchname> <startpoint> creates a completely new story that starts at the specified point, but does not have any of these parents commit.)

+12
source

In accordance with the project settings, I would prefer

1) create a new repo for v1

 git checkout v1 git remote add v1_repo git@gitlab.com :andrej/project-v1.git git push v1_repo v1:master 

2a) merge v2 with the master branch.

 git checkout master git merge v2 

2b) if you insist on creating 2 new projects, you can create a new project from the just merged wizard:

 git remote add v2_repo git@gitlab.com :andrej/project-v2.git git push v2_repo master 

3) You can tidy up the original repo by deleting branches v1 and v2:

 git checkout master git branch -D v1 git branch -d v2 

Here you should use -D to force removal of branch v1 because branch v1 not been merged.

0
source

All Articles