window环境使用git-filter-repo

本地环境git >= 2.36.0 python3 >= 3.6

1. 找到你下载的文件

你从 GitHub 下载解压后,里面有一个 没有后缀的文件:

复制代码
git-filter-repo

把它复制出来。

2. 粘贴到 你要清理的项目根目录

比如你的项目是:

复制代码
D:\my-project\

就把 git-filter-repo 粘贴到这里:

复制代码
D:\my-project\git-filter-repo

3. 打开 Git Bash,进入项目目录

复制代码
cd D:/my-project

二、Windows 上直接使用的命令(复制就能跑)

最常用:清理 Git 历史里的超大文件(瘦身 .git)

复制代码
python git-filter-repo --strip-blobs-bigger-than 1M --force

如果你要删除某个特定文件

复制代码
python git-filter-repo --path 大文件名字 --invert-paths --force

如果你要拆分仓库

复制代码
python git-filter-repo --subdirectory-filter 文件夹名

三、如果提示 python 不是命令,换成这个

复制代码
py git-filter-repo --strip-blobs-bigger-than 1M --force

四、使用前必须做(防止出错)

备份项目(非常重要)

复制代码
cp -r . ../my-project-backup

如果提示工作区不干净

复制代码
git add .
git commit -m "tmp"

五、清理完成后,推送到远程

git-filter-repo 在重写仓库历史时,默认会清空所有远程仓库配置(这是它的安全机制,防止你误操作覆盖远程仓库),所以你现在的本地仓库和 GitHub/Gitee 等远程仓库的连接被断开了。

需要重新关联仓库

复制代码
git remote add origin 你的仓库地址 git remote add origin https://github.com/你的用户名/你的仓库名.git

git remote add origin 原仓库地址

git remote add upstream 上游仓库地址

git push -f origin main

超级总结

你从 GitHub 拉取下来之后,只需要做这一件事:

把 git-filter-repo 复制到项目目录

打开 Git Bash

运行:

复制代码
python git-filter-repo --strip-blobs-bigger-than 1M --force

✅ 搞定!

相关推荐
u1301301 小时前
GitHub 热榜项目:月榜(2026-10-31)
github
wflynn3 小时前
GitHub 日榜趋势速报 | 2026-10-30
开源·github
miofly4 小时前
Anthropic为Claude四款模型加水印,两款旧模型留调参漏洞
开源·github
m4Rk_4 小时前
【论文阅读】Agent 记忆机制(116):Hybrid Memory——用互补策展与离线巩固构建长期记忆
论文阅读·人工智能·学习·开源·github
u1301307 小时前
GitHub 热榜项目:日榜(2026-10-31)
github
-梅7 小时前
GitHub Actions 自动化:5 个真实运维提效案例
运维·自动化·github
miofly7 小时前
GitHub 周榜趋势速报 | 2026-11-01
开源·github
miofly7 小时前
GitHub 日榜趋势速报 | 2026-11-01
开源·github
Sakura_j_h_16 小时前
EasyEDA PCB 快速设计Skills
c++·python·github
wflynn19 小时前
GitHub 今日推荐|Edge0:让大号 MoE 模型在一台 Mac 上流式跑起来
python·开源·github