Issue with Branch creation

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
Accepted answer

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'


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.

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

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.

I would echo Tim's statement, and suggest having a look at your branching options in more detail. Some information can be found here: 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
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,959 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you