[Git]克隆仓库报错warning:remoteHEADreferstononexistentref,unab
- 手机
- 2025-09-12 09:09:01
![[Git]克隆仓库报错warning:remoteHEADreferstononexistentref,unab](/0pic/pp_68.jpg)
问题:
从远程仓库clone项目,报错warning: remote HEAD refers to nonexistent ref, unable to checkout,只拉取到了隐藏.git文件夹。
gamin yunjuke % git clone http://git.whizape /ck/MF_APP_H5.git Cloning into 'MF_APP_H5'... remote: Enumerating objects: 1119, done. remote: Counting objects: 100% (1119/1119), done. remote: Compressing objects: 100% (1061/1061), done. remote: Total 1119 (delta 715), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (1119/1119), 1.11 MiB | 629.00 KiB/s, done. Resolving deltas: 100% (715/715), done. warning: remote HEAD refers to nonexistent ref, unable to checkout gamin yunjuke % cd /Users/gamin/Documents/yunjuke/MF_APP_H5 gamin MF_APP_H5 % git branch gamin MF_APP_H5 % git branch -r origin/master gamin MF_APP_H5 % git checkout master branch 'master' set up to track 'origin/master'. Switched to a new branch 'master' gamin MF_APP_H5 % git pull Already up to date. 解决: 1. 查看远程仓库的分支列表在克隆完成后,进入克隆的仓库目录:
cd MF_APP_H5运行以下命令查看远程仓库的分支: 注意,这里用git branch获取不到分支明显。
git branch -r你会看到类似的输出:
origin/feature-branch origin/main origin/master如果 git branch -r 没有列出任何分支,说明远程仓库确实是空的,或者没有任何有效的分支。
2. 手动切换到某个分支如果远程仓库有分支,你可以手动切换到一个有效的分支。例如,切换到 main 分支:
git checkout main如果远程仓库的默认分支是 master,而不是 main,可以执行:
git checkout master这将会切换到你选择的分支并检出代码。
3.拉取项目切换分支后,重新拉取项目就可以了。
git pull[Git]克隆仓库报错warning:remoteHEADreferstononexistentref,unab由讯客互联手机栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“[Git]克隆仓库报错warning:remoteHEADreferstononexistentref,unab”
上一篇
深度学习模型与前端结合
下一篇
CAP定理和BASE理论趣学!