Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to create a new branch from a branch which is not current?

I have seen git branch <newBranchName> will create a new branch from the current branch. So for example if my current branch is master then git branch build5 will create a new branch build5 based on master.

But if my current branch is master and I have another branch build3 and I want to create a new branch build6 based on build3, how can I do that? Is it possible to do it without switching from my current branch master?

Thanks

like image 283
ChumboChappati Avatar asked Sep 09 '15 22:09

ChumboChappati


1 Answers

Try this

git branch build6 build3

or

git checkout -b build6 build3

As you can see, git branch takes an optional parameter of a destination branch or commit from which to branch off of.

like image 140
CollinD Avatar answered Oct 02 '22 18:10

CollinD