Git'致命的:没有这样的ref:HEAD' [英] Git 'fatal: No such ref: HEAD'

查看:352
本文介绍了Git'致命的:没有这样的ref:HEAD'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个奇怪的事情发生在我的git仓库中。当我尝试在tortoisegit窗口中提交某些东西时,我会收到项目中的所有文件。我无法恢复他们,当我从服务器拉我收到致命:没有这样的ref:HEAD 致命:无法锁定ref'HEAD' code>。我所有的当地分店都失踪了。有什么办法可以解决这个问题吗?



这不是第一次提交或者其他的东西。这件事情突然间发生了。



编辑:

git branch -a 说:未能将HEAD解析为有效的ref



git状态打印标记为新文件的所有项目文件。



我更改了资料库文件夹名称一段时间,并且当我将它改回时, 。

解决方案

您已经失去了 HEAD 重新创建它。最简单的做法是这样的。

  echo ref:refs / heads / master> .git / HEAD 

现在您应该可以运行其他git命令并查看您的位置。



(理论上你可以尝试做 git symbolic-ref HEAD refs / heads / master 新版git版本不能识别 .git 作为git存储库,除非它已经包含 HEAD ,所以这将无法创建新的存储库。 )

A weird thing happend to my git repository. When I try to commit something in tortoisegit window I receive all files from project. I cannot revert them, when I pull from server I receive fatal: No such ref: HEAD and fatal: Cannot lock the ref 'HEAD'. All my local branches are missing. Is there any way to resolve the problem?

This is not first commit or something. This thing happend suddenly.

EDIT:

git branch -a says: Failed to resolve HEAD as a valid ref

git status prints all project files marked as new file.

I changed repository folder name for a while, and when I changed it back things were not correct.

解决方案

You've lost your HEAD so you'll need to recreate it. The simplest thing to do is this.

echo ref: refs/heads/master >.git/HEAD

Now you should be able to run other git commands and see where you're at.

(Although, in theory, you could attempt to do git symbolic-ref HEAD refs/heads/master newer git versions don't recognize a .git as a git repository unless it already contains a HEAD so this won't work to create a new one.)

这篇关于Git'致命的:没有这样的ref:HEAD'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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