git push失败:存在超过100MB的文件

报错原因:

commit的文件list中存在大文件,导致无法push

remote: warning: File logs/unsup-Stack/DyHATR_small_0.001000/entity2vec is 89.35 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: Trace: 5e559a5e91ec5f06951b01b4d72e4c1a87133a05a84126141d2ade0dc75f773f
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File dataset/dblp/dblp.xml is 2941.48 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/qycss/DHEmbedding.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/qycss/DHEmbedding.git'

解决方法:

移除本次commit中的大文件

1. 移除大文件

从报错信息中查找哪些文件出错,然后使用命令git rm --cached <FileName>删除指定文件

  • File logs/unsup-Stack/DyHATR_small_0.001000/entity2vec is 89.35 MB
    • $ git rm --cached logs/unsup-Stack/DyHATR_small_0.001000/entity2vec
  • File dataset/dblp/dblp.xml is 2941.48 MB; this exceeds GitHub’s file size limit of 100.00 MB
    • $ git rm --cached dataset/dblp/dblp.xml

或者使用命令 find ./ -size +100M 查询所有大于100MB的文件

$ find ./ -size +100M
./.git/objects/pack/pack-3492a80b3ed78f8a83a2a1f8fd206e011fc9ee74.pack
./dataset/dblp/dblp.xml

rm后的状态:

$ git status

On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    dataset/dblp/dblp.xml
        deleted:    logs/unsup-Stack/DyHATR_small_0.001000/entity2vec

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        dataset/dblp/dblp.xml
        logs/unsup-Stack/DyHATR_small_0.001000/entity2vec

2. 重新提交

编辑commit log,完成后:wq保存退出

git commit --amend

此时的状态为:

$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        dataset/dblp/dblp.xml
        logs/unsup-Stack/DyHATR_small_0.001000/entity2vec

nothing added to commit but untracked files present (use "git add" to track)

然后正常 git push 即可

如果上述操作完成后还是无法解决问题,则可以运行如下命令删除有关某个文件的push操作:

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch <FileName>'

最后使用命令git gc 清除本地仓库缓存

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值