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

时间: 2024-11-10 admin IT培训

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

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 - .
remote: error: Trace: c42ade10239deffc45c2a2800135e242
remote: error: See  for more information.
To /******! [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

彻底解决