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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

23,813 views 26 12
Join discussion

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