git提交报错:remote: Please remove the file from history and try again.

1. 报错信息

remote: error: File: fba7046b22fd74b77425aa3e4eae0ea992d44998 500.28 MB, exceeds 100.00 MB.
remote: Please remove the file from history and try again.
git rev-list --objects --all | grep fba7046b22fd74b77425aa3e4eae0ea992d44998

2. 分析原因

exceeds 100.00 MB.
提交的单个文件超过 100M

3. 解决办法

  • 这里使用的是回退提交的方式,进行解决
  • 别的方法可以参考

3.1 先查看超大的文件

 git rev-list --objects --all | grep fba7046b22fd74b77425aa3e4eae0ea992d44998

刪除对应大文件的提交,并添加到要忽略的文件

3.2 查看commit 提交记录

git reflog
或
git log

如下图:
git提交报错:remote: Please remove the file from history and try again._第1张图片

3.3 回退提交的版本

执行指令:

// 方式一:
git reset --hard commitID

// 方式二:
$ git reset --hard HEAD^

方式一:commitID:表示需要回退到的版本的Id;
方式二:用HEAD表示当前版本,上一个版本就是HEAD^
上上一个版本就是HEAD^^,
当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。

你可能感兴趣的:(日常报错记录-后端,git)