大 File 拒绝
错误信息
remote: 错误: File <name> 是 <大小> MB; 这个 exceeds GitHub's file 大小限制的 100 MB
快速摘要
file 你是 pushing 是也大 for remote (GitHub 限制 files 到 100 MB). 你需要 Git LFS or 到移除 file.
为什么发生
binary file (video, 数据库, archive) exceeds 100 MB
构建 artifact or 数据 file 是 accidentally committed
Dependencies or compiled 输出是不 gitignored
最小示例
✗ 错误代码
git add large-video.mp4
git commit -m "Add video"
git push # error: file exceeds 100 MB limit✓ 修复代码
# Remove the file from the commit
git rm --cached large-video.mp4
echo "*.mp4" >> .gitignore
git add .gitignore
git commit --amend -m "Ignore large videos"
git push # succeeds
# Or use Git LFS:
git lfs install
git lfs track "*.mp4"
git add .gitattributes
git add large-video.mp4
git commit -m "Add video via LFS"移除大 file 从 history and 添加它到 .gitignore, or use Git LFS 到 track 大 files properly.
如何诊断
Identify 大 file 从错误消息
检查如果 file 是 tracked: git ls-files | grep <filename>
Determine 如果 file 应该是 in 仓库 at 所有
如何修复
移除 file 从 history: git 筛选-分支 or git 筛选-仓库 --path <file> --invert-paths
添加 file 到 .gitignore 到 prevent future 提交
Use Git LFS for 大 files 那个必须是 tracked: git lfs track '<模式>'
如果 file 是不需要, 删除它 and 提交 removal
如何预防
添加大 file 模式到 .gitignore (e.g. *.mp4, *.zip, *.db)
Use Git LFS for 大 binary assets 那个必须是 version-controlled
检查 file 大小之前 committing