【git】执行 update_ref 失败:cannot lock ref "xxxxx" or "unable to delete 'xxxxxx': remote ref does not exist"
参考地址:https://zhuanlan.zhihu.com/p/181298491 https://blog.csdn.net/sgs595595/article/details/72480346
问题:当我执行 git push origin tet1(test1为分支名称,仅作为示例),有如下提示:
'refs/remotes/origin/test1' 执行 update_ref 失败:cannot lock ref 'refs/remotes/origin/users/test1': 'refs/remotes/origin/testBefore'(说明:testBefore为之前我提交过的分支,但是我已经在remote端删除该分支) 已存在,无法创 建'refs/remote/origin/test1'。
解决方案:
1. 我先在界面上查看remote所有的分支,并没有找到/origin/testBefore。
2. 执行命令:"git branch -r"(列出remote端所有的分支),发现有/origin/testBefore分支。
3. 执行命令:"git push orgin --delete origin/testBefore"(删除remote 分支),提示:
error: unable to delete 'origin/testBefore': remote ref does not exist
error: 推送一些引用到 'xxxxx' 失败。
解决方案: 分支名称删除origin, 尝试用命令 "git push orgin --delete testBefore"(删除remote 分支)进行删除,删除成功。
如果上面不成功的话,接着尝试下面的方法。
4. 执行命令:git fetch --prune origin(清除远程已经不存在的分支的跟踪分支)。
5. 再执行命令:git branch -r,发现remote端已经没有/origin/testBefore分支了。
note: 还是需要再深入研究,譬如 git fetch的用法,参考地址的第二篇博客中写到的那样,要进行实操试试。

浙公网安备 33010602011771号