Git无法锁定参考"HEAD":无法解析参考HEAD [英] Git cannot lock ref 'HEAD': unable to resolve reference HEAD
问题描述
我正在尝试将更改提交到我的存储库,但收到以下错误:
I'm trying to commit the changes to my repository but I receive the error below:
git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F C:\Users\Contronym\AppData\Local\Temp\bkdweixb.mnu
fatal: cannot lock ref 'HEAD': unable to resolve reference HEAD: Invalid argument
Completed with errors, see above.
我正在使用bitbucket和SourceTree.
I'm using bitbucket and SourceTree.
此提交失败的原因是什么?在过去一周中,我能够很好地完成最后3次提交.然后,突然,我收到了这个错误.
What's the reason for this commit failing? I was able to commit just fine the last 3 commits over the past week. Then, all of a sudden, I receive this error.
编辑
我运行了git gc
,结果如下:
$ git gc
error: bad ref for HEAD
error: bad ref for HEAD
error: inflate: data stream error (unknown compression method)
fatal: loose object 53b65bd9b4fec7f6a7b0b3313c68199a18804327 (stored in .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327) is corrupt
error: failed to run repack
我检查了目录.git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327
,但该目录不存在.还有另外两个文件,但是b65bd9b4fec7f6a7b0b3313c68199a18804327
不存在.
I checked the directory .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327
but that doesn't exist. There's two other files there, but b65bd9b4fec7f6a7b0b3313c68199a18804327
doesn't exist.
推荐答案
我遇到了同样的问题,发现的唯一解决方案是像这样导航到头部:
I had the same problem and the only solution that I found was to navigate to the head like so :
.git/refs/heads/branch_name
.git/refs/heads/branch_name
然后我删除了头文件.然后我进入控制台,并使用了命令:
And I deleted the head file . Then I went to the console and I used the command :
git reset
然后所有文件都已取消登台,因此请添加它们,然后再提交.
Then all the files were unstaged so add them and commit them afterwards.
这篇关于Git无法锁定参考"HEAD":无法解析参考HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!