Split git branch into separate repo
According to project setup I would rather
1) create new repo for v1
git checkout v1
git remote add v1_repo [email protected]:andrej/project-v1.git
git push v1_repo v1:master
2a) merge v2
into master
branch.
git checkout master
git merge v2
2b) if you insist on making 2 new projects then you can create new project from the newly merged master:
git remote add v2_repo [email protected]:andrej/project-v2.git
git push v2_repo master
3) You can tidy up original repo by deleting v1 and v2 branches:
git checkout master
git branch -D v1
git branch -d v2
You have to use -D
for force delete branch v1
here because v1
branch it was not merged.
The following assumes you have your two separate new repos set up as remotes named repo_v1
and repo_v2
.
The v1 branch is easy:
git push repo_v1 ref_c:v1
The v2 branch isn't that hard:
git checkout --orphan v2 ref_b
git cherry-pick ref_b..ref_d
git push repo_v2 v2
(git checkout --orphan <branchname> <startpoint>
creates an entirely new history that starts from the specified point but doesn't have any of that commit's parents.)