---
title: "homebrew 报错: homebrew-core is a shallow clone."
url: "https://yjyj.net/learn/6381.html"
author: "小 虾 (生猛大蝦编辑部)"
published_at: "2023-01-18T18:36:06+08:00"
updated_at: "2025-01-19T23:04:20+08:00"
categories: "招数学习"
tags: "Git版本控制, homebrew, Linux运维, macOS效率技巧"
summary: "本文聚焦 Homebrew 更新时报出“homebrew-core is a shallow clone”的常见故障，解释报错原因与官方提示背后的限制，并给出最直接的修复思路：删除相关 tap 后重新升级。适合遇到 brew update 卡住、浅克隆仓库异常的用户快速排障。"
source: "生猛大蝦 (https://yjyj.net)"
---

# homebrew 报错: homebrew-core is a shallow clone.

> 来源：[生猛大蝦 (yjyj.net)](https://yjyj.net/learn/6381.html) · 作者：小 虾 · 发布时间：2023-01-18

## 30 秒核心看点 (TL;DR)

- Homebrew 更新报错多半不是命令写错，而是 homebrew-core 浅克隆状态异常。
- 先按提示处理仓库，再执行 brew upgrade，能快速绕开 shallow clone 限制。
- 本文给出最省事的修复路径：删掉 core/cask tap 后重建，适合实战排错。

年末打算更新下homebrew, 没想到竟然报错:

```
Error: 
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
```

解决办法如下:

```
cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
rm -rf homebrew-cask
brew upgrade
```

## 延伸问答与排错指南 (FAQ)

### homebrew-core is a shallow clone 怎么修复？
先进入 /usr/local/Homebrew/Library/Taps/homebrew 目录，删除 homebrew-core 和 homebrew-cask 两个目录，再执行 brew upgrade。这样可以让 Homebrew 重新拉取完整仓库，绕开浅克隆导致的更新失败。

### 为什么 brew update 会提示 shallow clone？
因为 homebrew-core 仓库是浅克隆状态，更新时需要补全历史提交。Homebrew 为避免在大仓库上反复执行昂贵的 unshallow 操作，会直接提示用户手动处理。

### 执行 unshallow 和直接删目录重装有什么区别？
unshallow 是把浅克隆补全为完整仓库，适合保留现有仓库状态；删除 tap 目录则更粗暴，适合快速修复。本文给出的做法偏实战，目标是尽快恢复 brew 正常升级。

---
更多 Linux 运维、WordPress 性能优化、前端工程化、Shopify 独立站与极客折腾指南：[生猛大蝦全站文章归档 (https://yjyj.net/archive)](https://yjyj.net/archive)
