GitHub 上传文件过大报错:remote: error: GH001: Large files detected.

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

\(\color{red}{P.S.}\)如果报错:

Cannot rewrite branches: Your index contains uncommitted changes.

解决:

git stash

3.推送修改后的repo

git push origin master --force

4.清理和回收空间

虽然上面我们已经删除了文件, 但是我们的repo里面仍然保留了这些objects, 等待垃圾回收(GC), 所以我们要用命令彻底清除它, 并收回空间,命令如下:

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now

彻底解决。


引用:https://blog.csdn.net/qq997843911/article/details/88979051

posted @ 2019-11-28 10:09  Shaw_喆宇  阅读(3330)  评论(0编辑  收藏  举报