[英]How do I fix the git repo to remove a update_ref error for a folder which already exists?
I get the following error when I try to git push
a branch documentation/manifest
:当我尝试git push
分支documentation/manifest
时出现以下错误:
error: update_ref failed for ref 'refs/remotes/origin/documentation/manifest': cannot lock ref 'refs/remotes/origin/documentation/manifest': 'refs/remotes/origin/documentation' exists; cannot create 'refs/remotes/origin/documentation/manifest'
The steps which led up to this error were:导致此错误的步骤是:
documentation/manifest
and did some work on it, committing the work.创建了一个本地分支documentation/manifest
并对其进行了一些工作,提交了工作。documentation
.无法推送,因为有一个现有的 3 年陈旧的分支,名为documentation
。documentation
on github.删除了 github 上的分支documentation
。I've looked up some similar questions such as Git error when pushing - update_ref failed , however this was dealing with a different cause - it was not clear to me if the suggested solutions to that answer would help in this case, and as they seemed quite low-level they could equally well mess things up in a different way.我查看了一些类似的问题,例如Git 推送时出错 - update_ref failed ,但是这是处理不同的原因 - 我不清楚该答案的建议解决方案是否会在这种情况下有所帮助,并且看起来相当低级的他们同样可以以不同的方式把事情搞砸。
So, what do I need to do to get rid of this error whenever I push this branch?那么,每当我推送这个分支时,我需要做什么来摆脱这个错误?
I believe the problem is that you still have a local reference to the former remote documentation
branch, because the error messages says cannot create 'refs/remotes/origin/documentation/manifest'
, which would indeed be the case if refs/remotes/origin/documentation
already exists as a regular file.我认为问题在于您仍然对以前的远程documentation
分支有本地引用,因为错误消息说cannot create 'refs/remotes/origin/documentation/manifest'
,如果refs/remotes/origin/documentation
确实是这种情况refs/remotes/origin/documentation
已作为常规文件存在。
Removing the old local references should solve this problem:删除旧的本地引用应该可以解决这个问题:
git fetch -p
And if that doesn't work, you can even manually delete the problem file:如果这不起作用,您甚至可以手动删除问题文件:
rm .git/refs/remotes/origin/documentation
which you know is safe, since you deleted the documentation
branch on origin.您知道这是安全的,因为您删除了原始documentation
分支。
Relevant reference:相关参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.