创建(功能)子分支会导致错误“致命:无法锁定引用“refs/heads/feature/FeatureName”:“refs/heads/feature”存在”

发布于 2025-01-13 06:10:37 字数 514 浏览 5 评论 0原文

我试图创建一个功能子分支,feature/featureName

我的团队中存在一些混乱,因为我们中的一些人使用 SourceTree,而我们中的一些人使用 Git Bash。在 SourceTree 中,子分支列在 feature 下,我们假设这是一个“持有者分支”,然后您可以在其下创建子分支。

因此,我们的流程如下:

  • 创建并推送 maindevelopmentfeature 分支
  • 签出到 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, 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和我恋爱吧 2025-01-20 06:10:37

产生此错误的原因:

  • 如果存在名为a的分支,则无法创建名为a/b的分支(source)
  • 同样,如果有一个名为 a/b 的分支,则不能有名为 a/b/c 的分支 同样地
  • ,如果有一个名为a/b,无法创建名为a的分支。

我们误解了,要创建分类为 feature 的子分支,例如 feature/afeature/b您不应该创建'holder' 分支名为 feature !!!

相反,坚持只在其上创建 feature/afeature/b自己的。然后,Git GUI(例如 sourcetree)会将它们分类在自己的标题 feature 下,但请记住,这不是实际的分支。

希望有一天能帮助遇到这个问题的其他人!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文