git clone问题: warning: remote HEAD refers to nonexistent ref, unable to checkout

在git clone的时候出现如下warning:

 

 warning: remote HEAD refers to nonexistent ref, unable to checkout

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

eadc2c7d702724e788d8c6bcdb638b6b228e6ab5 refs/heads/another_branch

可以在此目录下使用 git branch -m anoter_branch master,将another_branch修改为master,这样再次克隆的时修就不会再有此warning。

 

还可以通过git rev-parse --all可以看到refs目录下所有的SHA值。

 

可以通过git rev-parse查看某一个branch,tag的SHA值,有没有办法反过来知道SHA的值知道其对应的branch以及tag呢,好像不可能?

 

注意:出现此问题的原因是,在本地将一个git工程拷贝过来,然后以此工程为基础,然后clone过来,由于本地只有my_topic所以clone过来的只有一个my_topic分支,此处不会再clone服务器远端的分支。

 

利用本地的bionic克隆的时候

git clone bionic local_bionic

然后

git remote show origin
* remote origin
  Fetch URL: /home/hebo/work/test/bionic
  Push  URL: /home/hebo/work/test/bionic
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    froyo-prod-bb
    my_topic
  Remote branches:
    froyo-prod-bb tracked
    my_topic      tracked
  Local branch configured for 'git pull':
    froyo-prod-bb merges with remote froyo-prod-bb
  Local ref configured for 'git push':
    froyo-prod-bb pushes to froyo-prod-bb (up to date)
此时看到的远程分支,是以当前克隆的对象为远程的,而bionic自已的远程分支无法再保留,而且所clone的仓库,当前在什么分支,clone在本地checkout出来的就是什么分支。

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值