Reputation: 47146
There is an branch xyz
for my master branch. I wanna create a new branch for the branch xyz
. How can I do this?
Upvotes: 2
Views: 440
Reputation: 497602
The primary ways to create branches are:
git branch <name> [start-point]
git checkout -b <name> [start-point]
The first just creates a branch, while the second creates and checks it out. If the start point is provided (e.g. master) then the branch is created at that point. If it's not, then it's created at whatever you currently have checked out.
In either case, it's really referring to the commit; there's no association between branches that's created. That is, git branch xyz master
doesn't create a branch "for" master, it just creates a branch at the commit master is currently at. If you never merge one back into the other, they'll never know about each other.
Upvotes: 5
Reputation: 104125
The branch is always created from the current branch. In other words, there’s nothing special here, simply git checkout -b xyz-branch
while on xyz
.
Upvotes: 1