git clone时,提示warning: remote HEA
2021-09-09 本文已影响0人
三也视界
git clone https://source.codeaurora.org/quic/lc/chromium/tools/depot_tools
输入以上命令后出现以下错误:
warning: remote HEAD refers to nonexistent ref, unable to checkout
输入 git show-ref查看git配置信息
57ed3aedaef3e9eabf9d8ea19f99ebbe8925b7be refs/remotes/origin/chromium.org/chrome/3865
9c96f7437ed546a93ba8b405d47265e50f1ca31c refs/remotes/origin/chromium.org/chrome/3904
5316f2b377a2c66279abaf35bc3f5971e4852ee4 refs/remotes/origin/chromium.org/chrome/3987
af45aa86aced54e87d3a5f061b504fd486694a27 refs/remotes/origin/chromium.org/chrome/4147
0b92d49c8c3e90e988288a63ea11dc2860387845 refs/remotes/origin/chromium.org/infra/config
06b1ab322c33dc5d5941521d26b24231efd30230 refs/remotes/origin/chromium.org/main
fc66578e93b33c85eeda3d5104d513217ae04be2 refs/remotes/origin/chromium.org/master
从输出的以上内容可以发现,没有类似refs/head/branch_name这样的refs
再次输入git branch -a查看所有分支
remotes/origin/chromium.org/chrome/3865
remotes/origin/chromium.org/chrome/3904
remotes/origin/chromium.org/chrome/3987
remotes/origin/chromium.org/chrome/4147
remotes/origin/chromium.org/infra/config
remotes/origin/chromium.org/main
remotes/origin/chromium.org/master
checkout 某个分支,以remotes/origin/chromium.org/master为例
git checkout remotes/origin/chromium.org/master
创建分支或切换到指定分支
git checkout -b remotes/origin/chromium.org/master
分支重命名
git branch -m remotes/origin/chromium.org/master master
输出:
error: refname refs/heads/origin/chromium.org/master not found
fatal: Branch rename failed
正常情况下,HEAD指向一个branch,而branch又指向一个commit。
detached HEAD state指的是HEAD指针没有指向任何的branch,而是指向了一个commit。
不去管它也可以提交,但是commit链就在git checkout这个commit的基础上展开,如果直接离开到一个branch上的话,这些commits就会被当成garbage,被git garbage collection routine所回收。那么如何保留这些commits?
有下面三种方式:
$ git checkout -b master ,创建一个branch指向这个commit链,然后HEAD指向这个branch,于是HEAD就不是处于detached state。
$ git branch master,创建一个branch指向这个commit链,但是HEAD还是处于detached state。
$ git tag master,创建一个tag指向这个commit链,HEAD还是处于detached state。
这里选择 git checkout -b master ,然后再关联远程分支,这样才可以进行git pull操作
git branch --set-upstream-to=origin/chromium.org/master master