You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unreal Engine项目Git历史清理求助:移除未被.gitignore排除的大文件

彻底移除Git历史中的目标文件夹

1. 确认目标路径

先明确要彻底删除的两个文件夹的项目相对路径,比如Unreal项目常见的Binaries/和Intermediate/,替换成你实际的目标路径。

2. 用git filter-repo清理历史

这是目前最安全高效的Git历史清理工具,替代老旧的filter-branch:

  • 先确保本地安装了git filter-repo(Mac可通过brew install git-filter-repo安装,Windows用Chocolatey或手动下载)
  • 进入项目根目录的终端,执行命令:
git filter-repo --path <第一个文件夹路径> --invert-paths
git filter-repo --path <第二个文件夹路径> --invert-paths

举个实际例子(如果目标是Binaries和Intermediate):

git filter-repo --path Binaries/ --invert-paths
git filter-repo --path Intermediate/ --invert-paths

3. 修复.gitignore

现在把两个目标文件夹添加到.gitignore,避免后续再提交:

Binaries/
Intermediate/

然后提交这个修复:

git add .gitignore
git commit -m "Fix .gitignore to exclude auto-generated folders"

4. 强制推送重写后的历史

因为修改了Git历史,必须强制推送到远程仓库:

git push origin master --force

注意:如果有其他协作开发者,一定要通知他们重新克隆仓库,旧的本地分支已经和远程历史不兼容,无法正常合并。

5. 清理本地冗余数据

执行命令清理本地Git缓存里的无用对象:

git reflog expire --expire=now --all
git gc --prune=now --aggressive

内容的提问来源于stack exchange,提问作者Nanako

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 17:08:16