1、概述
比如我从服务器上获取 DPDK 的代码:
发现看似代码下载下来了,但是 ls 下令后项目文件夹里的内容都是空的!!
可以看到最后有个 warning :warning: remote HEAD refers to nonexistent ref, unable to checkout.
2、缘故原由
git clone 代码时会默认拉取远程服务器 master 主分支下的代码,可是我创建的主分支没有效 master 命名,里面是 origin/20.11 分支,目录下 .git/refs/heads 不存在 HEAD 指向的文件,因此产生了告诫。
remotes/m/master -> origin/master //其余工程代码有master分支
上下对比:
remotes/m/master -> origin/20.11 //本工程代码分支没有master分支导致告诫
如下图显示:
3、解决方法
1、进入git clone 操纵后,天生的项目文件夹内,使用 git branch -a 检察全部的分支
- hwc@hwc:~/dpdk$ git branch -a
- remotes/origin/18.11.11
- remotes/origin/19.11.14
- remotes/origin/20.11
- remotes/origin/default
复制代码 2、选择自己必要的分支,比如我必要获取 origin/20.11 分支上的代码,那么实行操纵git checkout remotes/origin/20.11。
- hwc@hwc:~/dpdk$ git checkout origin/20.11
- Note: checking out 'origin/20.11'.
- You are in 'detached HEAD' state. You can look around, make experimental
- changes and commit them, and you can discard any commits you make in this
- state without impacting any branches by performing another checkout.
- If you want to create a new branch to retain commits you create, you may
- do so (now or later) by using -b with the checkout command again. Example:
- git checkout -b <new-branch-name>
- HEAD is now at d2d894a55f Add: supports the "set link-up/link-down" command.
复制代码 3、这时候 ls 下令就能看到你想要的代码
- hwc@hwc:~/dpdk$ ls
- app devtools examples lib Makefile mk test
- buildtools doc GNUmakefile license meson.build pkg usertools
- config drivers kernel MAINTAINERS meson_options.txt README
复制代码 4、新建一个分支后,操纵git log, git status等下令。
- hwc@hwc:~/dpdk$ git checkout -b dev-20.11
- Switched to a new branch 'dev-20.11'
复制代码 到此,解决问题!
谢谢点赞关注哈!
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |