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

相关推荐
Unity粉末状在校生1 天前
Git解决fatal: Could not read from remote repository.的问题
git
少年攻城狮1 天前
Obsidian系列---【如何使用obsidian同步到git?】
git
014-code1 天前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024061 天前
组合模式(Composite Pattern)
开发语言
游乐码1 天前
c#泛型约束
开发语言·c#
Dontla1 天前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen1 天前
python rest请求、requests
开发语言·python
铁东博客1 天前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang
baidu_huihui1 天前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳1 天前
Python从入门到精通day63
开发语言·python