用 brew cleanup 释放 Homebrew 占用的磁盘空间

brew cleanup 会删除旧版本 keg 和下载缓存;-s 同时清理下载缓存,--prune=all 清空全部缓存。

macOS清理Homebrew磁盘低风险
运行 `brew cleanup -s` 删除过期版本和缓存下载,或 `brew cleanup --prune=all` 彻底清空缓存。

01命令

命令
$ brew cleanup -s && brew cleanup --prune=all

02作用说明

Homebrew 默认保留 120 天的旧版本以便回滚,下载的 .tar.gz 也一直留在缓存里——活跃机器上能积累好几个 GB。正式清理前先用 `brew cleanup -ns`(dry run)预览会删除哪些内容。新版 Homebrew 在部分命令后会自动清理,但在 CI 和构建机上仍值得定期手动执行 `brew cleanup -s`。

03风险

风险低风险
使用条件Homebrew (https://brew.sh)
!注意: --prune=all 会删除缓存的安装包——之后再安装对应软件需要重新下载。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • Homebrew Man Page
    Homebrew · vendor-doc · 2026-09-17
    依据: Documents brew cleanup (--scrub/-s to clear cache, --prune=all to remove all cached downloads) and the default 120-day retention.

最后验证: 2026-09-17 · 分类: 开发者

06相关方案