Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move a Git branch out into its own repository?

People also ask

How do I create a new branch and move it?

New Branches The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.


You can simply push a branch to a new repository. All of its history will go with it. You can then choose whether to delete the branch from the original repository.

e.g.

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

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

Creating a new, empty repository can be done with git init.


This will keep the history of all the branches, but make your copy point to the one branch in particular:

git clone -b newbranch CurrentRepo NewRepo

This does not 'move' anything, just makes a copy.