ChumboChappati
ChumboChappati

Reputation: 1544

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

Upvotes: 6

Views: 1819

Answers (1)

CollinD
CollinD

Reputation: 7573

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.

Upvotes: 11

Related Questions