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
-
Create an empty repositor
- This can be done on GitHub, by creating a new repository
- 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).
-
Now to move the branch to a this newly created repository
- Open the old repository / branch location in the terminal
- 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.
Example
git push https://github.com/username/newRepoName newBranch:master
- Delete the branch from old repository, if you like to clean-up.