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

相关推荐
czq_268671948711 小时前
Python打卡第46天
开发语言·python
2301_7671139813 小时前
点过“不再询问”就要检查:Claude Code权限文件也可能存着密钥
git·信息安全·claude code
Evand J14 小时前
【MATLAB例程介绍】(17)永磁同步电机(PMSM)基于自适应无迹卡尔曼滤波(AUKF)的电流噪声在线估计。测量噪声协方差自适应与转速估计对比仿真
开发语言·matlab·卡尔曼滤波·无迹卡尔曼滤波·pmsm·电机滤波
miofly15 小时前
Genie 4新增原生音频,实时世界模型加入声音生成
开源·github
BaiPeter15 小时前
ZPL文件预览
开发语言·c++
dong_junshuai15 小时前
每天一个开源项目#155 MuJoCo:从接触求解到控制时序的物理引擎
github
GitHub实测笔记15 小时前
eza 本机实测:一万文件 -l 中位 48ms、ls 21.5ms;脚本里裸跑 eza 输出为空
github
一条Go15 小时前
开源新生代雷达 · 第 04 期
github
一条Go15 小时前
告警指纹:一次故障为什么只产生一条 FIRING 记录
后端·架构·github
wyxspark15 小时前
在本地 AI 中实现绝对可复现:一份 12,810 条哈希的硬核工程记录
github