git commit的文件太大导致push失败解决方法

1、查看报错日志,找到那个大文件。

Counting objects: 15, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (15/15), 382.90 MiB | 1.88 MiB/s, done.
Total 15 (delta 8), reused 0 (delta 0)
remote: Resolving deltas: 100% (8/8), completed with 7 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://g
it-lfs.github.com.
remote: error: Trace: 32cfdd82801eb81f072baeca0f5ca78b
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File resultDataset/resultDataset/gplus_combined.csv is 1279.62 MB; this exceeds Git
Hub's file size limit of 100.00 MB
To git@github.com:LiXiaoRan/dataHandle.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:xxxxxxx.git'

文件路径
可以发现,是gplus_combined.csv 文件太大,超过了100Mb的限制。那么要处理的就是这个文件了。
2、重写commit,删除大文件
注意必须是双引号,不然会报错

git filter-branch --force --index-filter “git rm --cached --ignore-unmatch 文件名的相对路径” --prune-empty --tag-name-filter cat – --all

此处需要将文件名换成自己的报错文件。
有些人这里可能会报错:

git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch resultDataset/resultDataset/gplus_combined.csv' --prune-empty --tag-name-filter cat -- --all

解决方法:
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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值