how to create a sub branch under a branch?

Lets say i have a branch /levi and then it has a ticket under it like /levi/A-1234, is it possible to create another branch under /levi/A-1234/A-1234a

Structure to be:  
/levi \<-- git checkout -b /levi

/levi/A-1234&nbsp; \<--- git checkout -b /99levi/A-1234

/levi/A-1234/A-1234a \<-- what is the proper command for this.&nbsp;

thx

There’s no such thing as “sub-branches” in git. A branch is a method of referring to a commit that follows you as you create new commits on top of the last one it pointed to. If you choose to have a branch that has a / in the name, it doesn’t necessarily mean anything. Some people on large projects like to use a slash to indicate groupings of branches, like in one project I might use my initials or GitHub handle to indicate that it is my branch, for example: lee-dohm/branch-name-here or LD/branch-name-here. But as far as git is concerned there’s no structural difference between a branch named lee-dohm/branch-name-here and branch-name-here and some-text/some-other-text/still-more-text/man-this-is-getting-to-be-a-pain-to-type (other than the name of the branch, of course).

So, to directly answer your question, the command to create a branch with a specific name is one of:

# Any modern version of Git
git checkout --branch some-branch-name

# Git v2.23 or later
git switch --create some-branch-name

I hope that helps!

1 Like