14

I'm currently working on a project where we have a UI branch and a Services branch (not my branching design). We now need to separate them into two distinct repos. I am trying to find the best way to do this while preserving the history and not having the new repo track back to the old one.

Thanks in advance.

Ramratan Gupta
  • 1,056
  • 3
  • 17
  • 39
Ryan
  • 143
  • 1
  • 4
  • 1
    Possible duplicate of [git push branch to a new repo with a different name](https://stackoverflow.com/questions/19105934/git-push-branch-to-a-new-repo-with-a-different-name) – Charles Aug 19 '17 at 03:06

2 Answers2

19

You first have to add the new remote repository:

git remote add newrepo https://github.com/name.git

Then you could push your branch (yournewbranch) to this repository:

git push newrepo yournewbranch:master

If the master branch already exists you might force the update or push to an other branch on the new repository

Achim Knupfer
  • 206
  • 2
  • 3
0

You could simply clone the repo for every branch, and delete all other branches.

For example, to keep the ui branch:

git clone <url> ui
git remote remove origin
git checkout ui
git branch -D services
pishpish
  • 2,574
  • 15
  • 22