Branch to New Repo

Sometimes you start working a project by creating a branch in a repo and then you realise that the branch will take its own new form / product. In such a case you would like to convert the branch into a new separate repository. Here is how you can do this

  1. Create an empty repositor

    1. This can be done on GitHub, by creating a new repository

    2. Or create and empty folder in your PC and use the git init command in terminal to generate a new empty repository (ensure that you are at the new folder path in terminal).

  2. Now to move the branch to a this newly created repository

    1. Open the old repository / branch location in the terminal

    2. Use the git push command as below

    git push url://to/new/repository.git branch-to-move:new-branch-name

For a new repository, new-branch-name is typically master.


git push newBranch:master
  1. Delete the branch from old repository, if you like to clean-up.

Last updated