现在的位置: 首页 > 综合 > 正文

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

2014年06月03日 ⁄ 综合 ⁄ 共 1262字 ⁄ 字号 评论关闭

问题描述:

最近做Android开发,采用的是git管理代码,从git服务器上获取Contacts模块的代码:

git clone your-git-server

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

并且Contacts模块的代码并没有下载到工作区。


解决方法:

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

获得如下打印:

5fa0b60252ca2c10fa3c2e12780d351c047c802d refs/remotes/origin/branch_qc_origin
5fa0b60252ca2c10fa3c2e12780d351c047c802d refs/tags/XXXXXXXXXXXX
48dee3a5f7b9cac98349e949275c652e02b0b67e refs/tags/PXXXXV0.0.0B01-bringup
505a9bb0c6d815e6db561f7cb7ed0e20cd73ddde refs/tags/PXXXX_02550_201309260427
e2b211a3c9d8dabec9fe1018b4f7db5c953832ea refs/tags/PXXXX_bsp_02550_201309260422
0848e8b7922c78dbb364aa0e7c1b8375d16a70a3 refs/tags/branch_PXXXX_02550_201309190102
7384803be7c8866393b96ebaaa7e1b2b119654e7 refs/tags/branch_PXXXX_02550_201309200102
480f444dd26bb238aeaacf15da748ad861ea9378 refs/tags/branch_PXXXX_02550_201309210102

......

可以看出,全部是标签tag,并没有类似refs/head/branch_name

继续执行命令: 

git branch  //输入出空

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

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

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

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

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

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

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

至此,问题得到解决。




抱歉!评论已关闭.