-1

I was trying to create a feature sub-branch, feature/featureName.

There was some confusion amongst my team as some of us are using SourceTree and some of us are using Git Bash. In SourceTree, the subbranches get listed under feature, and we assumed this was a 'holder branch' which you then create subbranches under.

Thus, our process was as follows:

  • Created and pushed a main, development, and feature branch
  • Checked out to development
  • Tried to create feature/featureName
  • Got the error fatal: cannot lock ref 'refs/heads/feature/FeatureName': 'refs/heads/feature' exists

We did not understand why this was happening. Luckily we found out!

KamielDev
  • 481
  • 3
  • 13

1 Answers1

0

Why this error was caused:

  • If there is a branch called a, no branch named a/b can be created (source)
  • Likewise, if there is a branch called a/b, no branch called a/b/c can be created
  • Likewise, if there is a branch called a/b, no branch named a can be created.

We misunderstood that to create subbranches that are categorised under feature, like feature/a or feature/b, you should not create a 'holder' branch named feature !!!

Instead, stick with just creating just feature/a and feature/b on their own. Git GUI's like sourcetree will then categorize these under their own header feature, but keep in mind that that is not an actual branch.

Hopefully this one day helps someone else who ran into this issue!

KamielDev
  • 481
  • 3
  • 13