git branch -r 远程分支显示不全

找回csdn帐号了,计划陆续开始更新最近的笔记√ 没想到很久没登还有人在看

问题描述

git 查看项目远程分支:

BASH 复制代码
git branch -r

返回结果很少。但GitHub页面上能看到很多的分支。

尝试git remote update,发现结果仍然如此。

shell 复制代码
PS C:\Users\dell\go\src\k8s.io\kubernetes> git remote update                                   
remote: Enumerating objects: 1334961, done.
remote: Counting objects: 100% (1334920/1334920), done.
...
Resolving deltas: 100% (981759/981759), completed with 7193 local objects.
From https://github.com/kubernetes/kubernetes
   49768134e52..160fe010f32  master         -> origin/master
 * [new tag]                 v0.10.0        -> v0.10.0
 * [new tag]                 v0.11.0        -> v0.11.0
...
 * [new tag]                 v1.9.0-alpha.3 -> v1.9.0-alpha.3
PS C:\Users\dell\go\src\k8s.io\kubernetes> git branch -r
  origin/HEAD -> origin/master
  origin/master

原因分析

当初拉取项目时,使用了 git clone --depth=1 ...

If you clone with the --depth parameter, it sets .git/config not to fetch all branches, but only master.

解决方法

在项目的 .git/config 文件中,修改一行:

You can simply omit the parameter or update the configuration file from / 找到这一行:

复制代码
fetch = +refs/heads/master:refs/remotes/origin/master

to / 改成:

复制代码
fetch = +refs/heads/*:refs/remotes/origin/*

Ref

https://git-scm.com/book/en/v2/Git-Internals-The-Refspec

相关推荐
white-persist4 分钟前
Python实例方法与Python类的构造方法全解析
开发语言·前端·python·原型模式
千里马-horse5 分钟前
Async++ 源码分析8--partitioner.h
开发语言·c++·async++·partitioner
Lucis__1 小时前
再探类&对象——C++入门进阶
开发语言·c++
007php0071 小时前
某大厂跳动面试:计算机网络相关问题解析与总结
java·开发语言·学习·计算机网络·mysql·面试·职场和发展
lsx2024062 小时前
HTML 字符集
开发语言
很㗊2 小时前
C与C++---类型转换
c语言·开发语言
say_fall2 小时前
精通C语言(3. 自定义类型:联合体和枚举)
c语言·开发语言
郝学胜-神的一滴2 小时前
Effective Python 第43条:自定义容器类型为什么应该从 `collections.abc` 继承?
开发语言·python
jndingxin2 小时前
c++多线程(6)------ 条件变量
开发语言·c++
共享家95272 小时前
QT-常用控件(二)
开发语言·qt