Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复git repo以删除已存在文件夹的update\u ref错误?_Git_Github - Fatal编程技术网

如何修复git repo以删除已存在文件夹的update\u ref错误?

如何修复git repo以删除已存在文件夹的update\u ref错误?,git,github,Git,Github,当我尝试git推送分支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/re

当我尝试
git推送分支
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'
导致此错误的步骤包括:

  • 从远程repo(github)克隆
  • 创建了一个本地分支
    文档/manifest
    ,并对其进行了一些工作,提交了工作
  • 推着树枝。无法推送,因为存在一个名为
    documentation
    的已存在3年的过时分支
  • 删除了github上的分支
    文档
  • 又推了一下。Branch将OK推到remote,我可以确认它是否存在,但每次推后都会出现上述错误。考虑到这一点,我认为这是一个局部错误
  • 我查阅了一些类似的问题,例如,然而,这是处理一个不同的原因-我不清楚这个答案的建议解决方案在这种情况下是否会有所帮助,而且由于它们看起来相当低级,它们同样可以以不同的方式把事情搞得一团糟


    那么,每当我推这个分支时,我需要做什么来消除这个错误呢?

    我认为问题在于您仍然有一个对前一个远程
    文档
    分支的本地引用,因为错误消息说
    无法创建“refs/remotes/origin/documentation/manifest”
    ,如果
    refs/remotes/origin/documentation
    已作为常规文件存在,则情况确实如此

    删除旧的本地引用可以解决此问题:

    git fetch -p
    
    如果不起作用,您甚至可以手动删除问题文件:

    rm .git/refs/remotes/origin/documentation
    
    您知道这是安全的,因为您删除了源上的
    文档
    分支

    相关参考资料:

    • 有关本地参考的相关问题,此处也适用于远程参考:

    非常好,谢谢
    git fetch-p
    修复了它!