git提交代码到远程仓库错误,如下图
9:50 Fetch Failed
cannot lock ref 'refs/remotes/origin/dev': unable to resolve reference 'refs/remotes/origin/dev': reference broken
From https://g.hz.netease.com/mis/fin/yq/api/yq-api
! [new branch] dev -> origin/dev (unable to update local ref)
cannot lock ref 'refs/remotes/origin/feature/create-invoice-change-to-ap-zxjin': unable to resolve reference 'refs/remotes/origin/feature/create-invoice-change-to-ap-zxjin': reference broken
! [new branch] feature/create-invoice-change-to-ap-zxjin -> origin/feature/create-invoice-change-to-ap-zxjin (unable to update local ref)
cannot lock ref 'refs/remotes/origin/feature/xy-账务多语言': unable to resolve reference 'refs/remotes/origin/feature/xy-账务多语言': reference broken
! [new branch] feature/xy-账务多语言 -> origin/feature/xy-账务多语言 (unable to update local ref)
cannot lock ref 'refs/remotes/origin/feature/zjl-invoice': unable to resolve reference 'refs/remotes/origin/feature/zjl-invoice': refer... (show balloon)
网上有推荐命令:
git gc --prune=now
git remote prune origin
尝试执行后失败
Microsoft Windows [版本 10.0.19045.3930]
(c) Microsoft Corporation。保留所有权利。
D:\myProjects\dms-api\src\main\java\com\netease\dms>git gc --prune=now
error: bad ref for .git/logs/refs/remotes/origin/dev
error: bad ref for .git/logs/refs/remotes/origin/feature/create-invoice-change-to-ap-zxjin
error: bad ref for .git/logs/refs/remotes/origin/feature/xy-账务多语言
error: bad ref for .git/logs/refs/remotes/origin/feature/zjl-invoice
error: bad ref for .git/logs/refs/remotes/origin/HEAD
error: bad ref for .git/logs/refs/remotes/origin/release
error: bad ref for .git/logs/refs/remotes/origin/uat
fatal: bad object refs/remotes/origin/HEAD
fatal: failed to run repack
解决方法,到项目的.git 目录下
进入refs/remotes/origin/
删除所有内容
重新提交OK
参考网址:【Git】fatal: bad object refs/remotes/origin/xxx_did not send all necessary objects-CSDN博客