当我尝试从
test/hotfix
分支结帐 test
分支时:
git checkout -b test/hotfix
显示错误:
fatal: cannot lock ref "refs/heads test/hotfix refs/heads/test' exists;cannot create refs/heads/test/hotfix
我已经像这样检查了当地的分支机构:
-> git branch
develop
develop_zxg
feature/jxq_order
jiangxiaoqiang/order
master
test
没有
test/hotfix
分支。我也尝试过这个命令:
git update-ref -d refs/heads/origin/branch
仍然没有解决这个问题。有人面临同样的问题吗?
分支命名中有一个小问题:git 在你的文件系统上有实际的文件来代表分支(检查
tree .git/refs/heads
以查看该分支),并且你不能拥有同名的文件和目录。
这反映在分支的命名规则中:您不能同时拥有名为
test
的分支和 名为 test/hotfix
的分支。
摆脱您的
test
分支(将其删除,或重命名:git branch -m test test-mine
或 git branch -m test test/mine
),或为您的 test/hotfix
分支选择其他名称。