一.环境
发行版:Ubuntu 18.04.1 LTS
代号:bionic
内核版本:4.15.0-30-generic
二.背景
git clone https://source.codeaurora.org/external/qoriq/qoriq-components/openwrt
输入以上命令后出现以下错误:
warning: remote HEAD refers to nonexistent ref, unable to checkout
三.解决
3.1 git show-ref输出以下内容:
26d93b38e8acb69a96614675db70fd082e738c05 refs/remotes/origin/github.lede-project/brcm47xx-lxl
01a8f0e444c9b52f100eff878cc7011fffeddeaf refs/remotes/origin/github.lede-project/lede-17.01
61a59949009993a6b1d634ecbce765b37c4c2560 refs/remotes/origin/github.lede-project/master
05606de1aa5bb84b7f60f2df15368268e4106acc refs/remotes/origin/github.lede-project/openwrt-18.06
09e04e4d113f3d766bf2ca1a8a58d872753d953f refs/remotes/origin/github.qoriq-os/integration
498e4fddb7a713007b32e19a14c44d21583e99bf refs/remotes/origin/integration
fb197e7eaae4a7f33c9f24f922b1f8c2225aa301 refs/tags/OpenWrt-18.02
458fcbd03d040848b4f688917b76773fd2d647fc refs/tags/OpenWrt-18.08
5e419b20de47b518c15ebff8d2370b14c0c4bde1 refs/tags/reboot
69d8988682d88bdf47bd453dd968838b0eb0f8dd refs/tags/v17.01.2
1edb66f5f051b003b0ad5fcc3a08acb9d0700d9e refs/tags/v17.01.3
a0a7b1065cfa073570186958c919b6ed04837d86 refs/tags/v17.01.4
f9d18e2bb1d1e008774b0da99c73625602d33bd5 refs/tags/v17.01.5
ea72e0b1f937357db7b8faec250ecd385e29f138 refs/tags/v17.01.6
d243cf3da5b88a15485cae19c9c2f0b8b9aa5caa refs/tags/v18.06.0
bd01c2d3a34145e4823ae62b99496c9a9b722a57 refs/tags/v18.06.0-rc1
373a8f47ac809b4bb0fdb56cfcdfcbe3bb2fda8e refs/tags/v18.06.0-rc2
b261a1195fca2b8b951203f0f1464d163455b9c3 refs/tags/v18.06.1
从输出的以上内容可以发现,没有类似refs/head/branch_name这样的refs
3.2 git branch -a查看所有分支
remotes/origin/github.lede-project/brcm47xx-lxl
remotes/origin/github.lede-project/lede-17.01
remotes/origin/github.lede-project/master
remotes/origin/github.lede-project/openwrt-18.06
remotes/origin/github.qoriq-os/integration
remotes/origin/integration
3.3 checkout 某个分支,以remotes/origin/github.lede-project/openwrt-18.06为例
git checkout remotes/origin/github.lede-project/openwrt-18.06
3.4 创建分支或切换到指定分支
git checkout -b remotes/origin/github.lede-project/openwrt-18.06
3.5 分支重命名
git branch -m remotes/origin/github.lede-project/openwrt-18.06 openwrt-18.06
3.6 指定想要merge的分支,这样才可以进行git pull操作
git branch --set-upstream-to=origin/openwrt-18.06 openwrt-18.06