从git历史记录中删除大文件?

我们有一个远程git存储库,对文件没有大小限制,我们已经推入了300MB.然后我们实现了它,然后从存储库中删除了该文件.

同时将相同的存储库添加到github,当我们尝试将更改推送到github时,我们得到大文件大小错误.

remote: error: File dir/filename is 312.27 MB; this exceeds GitHub's file size limit of 100 MB

为了解决这个问题,我尝试使用How to remove/delete a large file from commit history in Git repository?建议的交互式git rebase解决方案,但是在rebase操作结束时,当我执行git状态时,我最终得到以下内容

[18:10:35] $git status
On branch master
Your branch and 'origin/master' have diverged,
and have 8 and 24 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

如果我使用git pull,那么我删除的所有更改都会被带回git存储库.我该如何解决?

最佳答案 如果我找对你,在变基之后你想做git push -f origin而不是git pull.这会按预期重写远程存储库历史记录.

注意强制推送到共享存储库可能会消除其他人的更改,并且只应在与所有访问者进行协商后才能完成.
此外,我建议您确保将来可以访问丢弃的origin / master历史记录(通过标记它或类似的东西),至少在每个人都同意rebase工作正常之前.

点赞