Please remove the file from history and try again.
git 2022-12-30 13:40:45

推送大文件到远程库报错: Please remove the file from history and try again.

 

提交代码时报错:

remote: Powered by GITEE.COM [GNK-6.4]

remote: error: File: af262e77f1a19b4697863f2f8a93dfbe43bc854b 292.76 MB, exceeds 100.00 MB.

remote: Use command below to see the filename:

remote: git rev-list --objects --all | grep af262e77f1a19b4697863f2f8a93dfbe43bc854b

remote: Please remove the file from history and try again. (https://gitee.com/help/articles/4232)

To https://gitee.com/xxxx.git

 ! [remote rejected]   master -> master (pre-receive hook declined)

error: failed to push some refs to 'https://gitee.com/xxxx.git'

 

应该是提交的文件中有超过100MB的。

解决方案:

1、按照提示执行命令查看超大的文件:

C/C++ Code复制内容到剪贴板
  1. git rev-list --objects --all | grep af262e77f1a19b4697863f2f8a93dfbe43bc854b  

 

2、执行命令忽略掉超大的文件

git rm --cached file_name

#如果是文件夹

git rm -r --cached directory_name

在.gitignore中添加要忽略的文件

然后执行commit。

 

3、在commit的提交历史里面去除这个超大文件

git filter-branch --tree-filter 'rm -f 文件名' HEAD

 

如果提示:

WARNING: Ref 'refs/heads/master' is unchanged

表示删除失败。

 

如果提示:

Ref 'refs/heads/master' was rewritten

表示删除成功。

 

然后执行push,OK。

 

 

 

本文来自于:http://www.yoyo88.cn/study/git/651.html

下一篇 返回列表
Powered by yoyo苏ICP备15045725号