0

I want to be able to create feature branches like dev/feature/JIRA_KEY_Issue_name.

When I try to do it using git checkout -b dev/feature/JIRA_KEY_Issue_name, I get an error like this:

fatal: cannot lock ref 'refs/heads/dev/feature/XXXXXXXXXXXXXXXX': 'refs/heads/dev' exists; cannot create 'refs/heads/dev/feature/XXXXXXXXXXXXXXXX'

When I try create that branch in GitLab, I get the error message that the name is invalid.

It is definitely possible to use branch names like this because one company I know does it (and they use GitLab, too).

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
  • 2
    You can't have a branch named X and another named X/Y, the X part is already a complete name, so you can't tuck more onto it. Since you already have a branch named `dev`, you can't make new branches that start with `dev/`. The technical reason is that in the references folder there is already a **file** named `dev`, but in order to create the hierarchical branch name you want to use, it has to be a **folder**. That's why you can have both `dev/a` and `dev/b`, inside that `dev` folder you will have two files, `a` and `b`, but you can't then also have a branch named just `dev`. – Lasse V. Karlsen Mar 16 '20 at 14:54
  • Does this answer your question? [git push: refs/heads/my/subbranch exists, cannot create](https://stackoverflow.com/questions/22630404/git-push-refs-heads-my-subbranch-exists-cannot-create) – phd Mar 16 '20 at 16:14
  • https://stackoverflow.com/search?q=%5Bgit%5D+fatal%3A+cannot+lock+ref+exists – phd Mar 16 '20 at 16:14

1 Answers1

2

Your repository seems to have a branch named dev.

Remove dev branch. Then you can create dev/feature/JIRA_KEY_Issue_name.

shirakia
  • 2,369
  • 1
  • 22
  • 33