4

I'm trying to create release/0.1.0 branch in Azure DevOps repo but getting error Name conflicts with refs/heads/release:
enter image description here

It doesn't matter based on what branch I'm trying to create,
it also works fine when I'm trying to create feature/0.1.0 branch

Is it a king of a permissions issue (I'm not admin in this Azure DevOps project)?

Community
  • 1
  • 1
kagarlickij
  • 7,327
  • 10
  • 36
  • 71
  • 1
    Does this answer your question? [Using the slash character in Git branch name](https://stackoverflow.com/questions/2527355/using-the-slash-character-in-git-branch-name) – grg Feb 19 '20 at 19:01

2 Answers2

8

This is purely a Git restriction. You can't create a branch "under" another branch.

You could create releases/0.1.0. But since there is already a release branch, you can't put a new branch underneath it.

Observe:

git status

On branch master
nothing to commit, working tree clean

git checkout -b master/foo

fatal: cannot lock ref 'refs/heads/master/foo': 'refs/heads/master' exists; 
cannot create 'refs/heads/master/foo'
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • If you have lots of git branches with the same naming pattern, it's possible to batch rename git branches stackoverflow.com/a/44570815/3281978 – tgrrr Apr 18 '22 at 05:13
6

A git limitation due to how Git store references as files (and folder tree) in the .git/refs/heads folder.

When you trying to create the branch release/0.1.0, Git tries to create the folder release to create a file named 0.1.0 inside it.

Because there is already a file named release corresponding to the branch already created, Git can't create a folder with the same name (the file system doesn't allow it).

Due to this limitation linked to how git handles ref through the file system, git doesn't allow this case and verify this type of case when you try to create it (even if refs are packed).

Philippe
  • 28,207
  • 6
  • 54
  • 78