Bitbucket: Why can't I create a master/x branch

Viewed 1396

(This is done in SourceTree)

I am trying to make some branches (master/dev, master/demo, master/live) but this cannot be pushed. For example, when I try to push master/demo to master/demo then it gives this error:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin master/demo:master/demo
fatal: HttpRequestException encountered.
   An error occurred while sending the request.

POST git-receive-pack (206 bytes)
remote: error: cannot lock ref 'refs/heads/master/demo': 'refs/heads/master' exists; cannot create 'refs/heads/master/demo'        
Pushing to https://x@bitbucket.org/x/x.git
To https://bitbucket.org/x/x.git
 ! [remote rejected] master/demo -> master/demo (failed to update ref)
error: failed to push some refs to 'https://x@bitbucket.org/x/x.git'



Completed with errors, see above.
1 Answers

Internally, branches are stored in .git/refs/heads folder as files. If a branch name contains a directory separator, a similar directory is created inside heads. The filesystem on the remote prevents you from having a file called master and a folder named master on the same path, so that's why you get an error.

You need to use something else than master as the prefix for your branches.

Related