美文网首页
Git:解决push后报文件过大的错误 -> remote: e

Git:解决push后报文件过大的错误 -> remote: e

作者: zbmzly | 来源:发表于2019-02-26 10:06 被阅读0次

https://stackoverflow.com/questions/19573031/cant-push-to-github-because-of-large-file-which-i-already-deleted
其中介绍的一个方法是使用以下代码:

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' HEAD

但是这个方法会影响history hash。所以不是很推荐。

还有一个比较好的方法:

  1. 删除那个过大的文件
  2. commit这个delete
  3. soft reset N次 commit,也就是回退N次commit,这里的N取决于你的需求
 git reset --soft HEAD~3
  1. 重复commit所有的更改(也叫做squash)
git commit -m "New message for the combined commit"
  1. push那个squashed commit

注意所有git命令都必须在git当前目录下执行。

相关文章

网友评论

      本文标题:Git:解决push后报文件过大的错误 -> remote: e

      本文链接:https://www.haomeiwen.com/subject/qsboyqtx.html