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, andfeaturebranch - 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!
Why this error was caused:
a, no branch nameda/bcan be created (source)a/b, no branch calleda/b/ccan be createda/b, no branch namedacan be created.We misunderstood that to create subbranches that are categorised under
feature, likefeature/aorfeature/b, you should not create a 'holder' branch namedfeature!!!Instead, stick with just creating just
feature/aandfeature/bon their own. Git GUI's like sourcetree will then categorize these under their own headerfeature, but keep in mind that that is not an actual branch.Hopefully this one day helps someone else who ran into this issue!