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'

Regards,
Ben

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: 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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

2,045 views 1 5
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