Git 无法锁定引用“HEAD":无法解析引用 HEAD [英] Git cannot lock ref 'HEAD': unable to resolve reference HEAD

查看:102
本文介绍了Git 无法锁定引用“HEAD":无法解析引用 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:UsersContronymAppDataLocalTempkdweixb.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,结果如下:

I ran git gc and these are the results:

$ 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 

然后我删除了头文件.然后我去了控制台,我使用了命令:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆