1.查看哪个文件过大了
remote: Resolving deltas: 100% (24/24), completed with 3 local objects.
remote: warning: File CPT_0707_ao/temp_past/temp2/deltap.csv is 71.69 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: c42ade10239deffc45c2a2800135e242
remote: error: See http://git.io/iEPt8g for more information.
To https://github.com/******
! [remote rejected] master -> master (pre-receive hook declined)
可以发现,是CPT_0707_ao/temp_past/temp2/deltap.csv 文件太大,超过了50Mb的限制。那么要处理的就是这个文件了。
2.重写commit,删除大文件
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch CPT_0707_ao/temp_past/temp2/deltap.csv' --prune-empty --tag-name-filter cat -- --all
3.推送修改后的repo
git push origin master
4.清理和回收空间
虽然上面我们已经删除了文件, 但是我们的repo里面仍然保留了这些objects, 等待垃圾回收(GC), 所以我们要用命令彻底清除它, 并收回空间,命令如下:
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
彻底解决
文章讲述了如何处理一个超过GitHub推荐大小限制的文件CPT_0707_ao/temp_past/temp2/deltap.csv。首先识别出是哪个文件过大,然后使用gitfilter-branch命令重写提交历史以删除该文件,接着推送修改后的仓库。最后,执行一系列git命令进行垃圾回收,确保已释放空间。
1272

被折叠的 条评论
为什么被折叠?



