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

✅ 搞定!

相关推荐
刘较瘦_3 小时前
AI 开发中的 Git Submodule 父子仓库模式:前后端分仓管理与协作实践
前端·github
DeMinds6 小时前
内容没有丢,我为什么总在重新整理?|DeMinds 如何让工作接着继续
ios·github·markdown
寒水馨6 小时前
macOS下载、安装openclaw-v2026.7.1(附安装包OpenClaw-2026.7.1.dmg)
macos·大模型·github·开源软件·ai助手·openclaw·gpt-5.6
徐小夕7 小时前
花了3天,我写了一款开源AI公众号编辑器
前端·vue.js·github
CCPC不拿奖不改名1 天前
大模型推理架构与开源生态知识整理
数据库·windows·python·架构·langchain·开源·github
redreamSo1 天前
一天涨 1800 星的 GitHub 榜首:AI 编程瓶颈变成了 token
人工智能·开源·github
逛逛GitHub1 天前
盘点 18 个 Kimi K3 外网爆火的案例,太令人惊艳了。
github
benchmark_cc1 天前
如何用 Python 进行多周期 K 线合成与时区对齐?基于 QuantDash 与 Pandas 的量化数据清洗实战(附 GitHub 源码)
开发语言·python·github·盯盘·pandas·quantdash·量化数据
luyingying1 天前
从 400 行到 30 个文件,我只做了一件事
github