创建(功能)子分支会导致错误“致命:无法锁定引用“refs/heads/feature/FeatureName”:“refs/heads/feature”存在”
我试图创建一个功能子分支,feature/featureName
。
我的团队中存在一些混乱,因为我们中的一些人使用 SourceTree,而我们中的一些人使用 Git Bash。在 SourceTree 中,子分支列在 feature
下,我们假设这是一个“持有者分支”,然后您可以在其下创建子分支。
因此,我们的流程如下:
- 创建并推送
main
、development
和feature
分支 - 签出到
development
- 尝试创建
feature/featureName
- 得到错误
致命:无法锁定引用'refs/heads/feature/FeatureName':'refs/heads/feature'存在
我们没有了解为什么会发生这种情况。幸运的是我们发现了!
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
, andfeature
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
产生此错误的原因:
a
的分支,则无法创建名为a/b
的分支(source)a/b
的分支,则不能有名为a/b/c
的分支 同样地a/b
,无法创建名为a
的分支。我们误解了,要创建分类为
feature
的子分支,例如feature/a
或feature/b
,您不应该创建'holder' 分支名为feature
!!!相反,坚持只在其上创建
feature/a
和feature/b
自己的。然后,Git GUI(例如 sourcetree)会将它们分类在自己的标题feature
下,但请记住,这不是实际的分支。希望有一天能帮助遇到这个问题的其他人!
Why this error was caused:
a
, no branch nameda/b
can be created (source)a/b
, no branch calleda/b/c
can be createda/b
, no branch nameda
can be created.We misunderstood that to create subbranches that are categorised under
feature
, likefeature/a
orfeature/b
, you should not create a 'holder' branch namedfeature
!!!Instead, stick with just creating just
feature/a
andfeature/b
on 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!