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。所以不是很推荐。
还有一个比较好的方法:
- 删除那个过大的文件
- commit这个delete
- soft reset N次 commit,也就是回退N次commit,这里的N取决于你的需求
git reset --soft HEAD~3
- 重复commit所有的更改(也叫做squash)
git commit -m "New message for the combined commit"
- push那个squashed commit
注意所有git命令都必须在git当前目录下执行。
网友评论