Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Issue with Branch creation

Vijay kumar September 27, 2015

Assume we have a branch Rel1 on Stash hosted git repo..and when we try to create a branch Rel1/JIRA1234 , we are getting an error stating the branch cannot be created, its name conflicts with an existing branch.

There is no such branch on the server. Are there any rules governing branch naming ?

1 answer

1 accepted

2 votes
Answer accepted
Ben Humphreys
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2015

Hi Vijay,

This is indeed a Git restriction and relates to how Git manages branch names (actually refs). Have a look in your .git/refs/heads directory and you will understand the restriction.

You can reproduce this behavior on the command line too. For example:

$ git branch Rel1
$ git branch Rel1/JIRA1234
fatal: cannot lock ref 'refs/heads/Rel1/JIRA1234': 'refs/heads/Rel1' exists; cannot create 'refs/heads/Rel1/JIRA1234'

Regards,
Ben

Rich Duncan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2015

Branches are not tree structures like they are in base ClearCase for example. You can create a branches in directories as a way to group them together. So for example if Rel1 wasn't a branch (the first line above was not executed), you could create Rel1/JIRA1234 as a well to group various Rel1 branches together.

Vijay kumar September 28, 2015

Thanks Ben & Rich...that makes a whole lot sense now. We now plan to create branches using "-" instead of "/". cheers Vijay

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2015

I wouldn't recommend that. A lot of features in both Stash and SourceTree take advantage of the "/" naming convention to let you treat similar branches similarly (i.e. feature/* branches, etc) I'd instead just try not to have a branch with the unadorned base name (i.e. Rel1 in this example). But that's just my thought.

Ben Humphreys
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2015

I would echo Tim's statement, and suggest having a look at your branching options in more detail. Some information can be found here: https://confluence.atlassian.com/display/BitbucketServer/Using+branches+in+Bitbucket+Server Some examples of branch names in this model are: release/1.0 release/2.0 bugfix/JIRA-123-a-serious-bug feature/JIRA-456-a-new-feature

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events