git clone时,提示warning: remote HEAD refers to nonexistent ref, unable to checkout.

来源:互联网 发布:卖家怎样开通淘宝达人 编辑:程序博客网 时间:2024/06/05 11:53

问题描述:

采用的是Git管理代码,从github上克隆代码:

git clone 我的项目名

提示:warning: remote HEAD refers to nonexistent ref, unable to checkout.

并且只显示.git文件


解决方法:

原因是.git目录下.git/refs/heads不存在HEAD指向的文件,这个时候可以用git show-ref命令查看

获得如下打印:

f73460e266dec525ca2f9480d3b2d254ce9a1325 refs/remotes/origin/dev

......类似

继续执行命令: 

git branch  //输入出空

git branch -a //输出 remotes/origin/dev

git checkout remotes/origin/dev // checkout的是git branch -a输出的内容

这样通过ll命令查看,代码下载到工作目录了

接着创建分支:git checkout -b remotes/origin/dev

git branch //可以看到输出*remotes/origin/dev了,不再为空

git branch -m remotes/origin/dev master  //重命名分支叫master

git show-ref命令查看也能看到head了

至此,代码都显示出来,问题得到解决。

阅读全文
1 0