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

相关推荐
极小狐10 分钟前
极狐GitLab 项目功能和权限解读
运维·git·安全·gitlab·极狐gitlab
极小狐17 分钟前
极狐GitLab 如何 cherry-pick 变更?
人工智能·git·机器学习·gitlab
投笔丶从戎28 分钟前
Kotlin Multiplatform--01:项目结构基础
android·开发语言·kotlin
杜小暑1 小时前
动态内存管理
c语言·开发语言·动态内存管理
想不明白的过度思考者1 小时前
Java从入门到“放弃”(精通)之旅——JavaSE终篇(异常)
java·开发语言
我真的不会C2 小时前
QT窗口相关控件及其属性
开发语言·qt
CodeCraft Studio2 小时前
Excel处理控件Aspose.Cells教程:使用 Python 在 Excel 中进行数据验
开发语言·python·excel
火柴盒zhang2 小时前
websheet之 编辑器
开发语言·前端·javascript·编辑器·spreadsheet·websheet
景天科技苑2 小时前
【Rust】Rust中的枚举与模式匹配,原理解析与应用实战
开发语言·后端·rust·match·enum·枚举与模式匹配·rust枚举与模式匹配
阿让啊2 小时前
C语言中操作字节的某一位
c语言·开发语言·数据结构·单片机·算法