Removing large file from git history?

左心房为你撑大大i 提交于 2019-12-21 05:31:11

问题


We have a remote git repository where there are no size restrictions for files and we had pushed a 300MB into it. We then realized it and then removed the file from the repository.

Meanwhile the same repository was added to github and when we try to push the changes to github, we get the large file size error.

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

To fix this, I tried using the interactive git rebase solution suggested at How to remove/delete a large file from commit history in Git repository?, but at the end of the rebase operation I end up with the following when I do git status

[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)

And if I use git pull then all the changes which I have removed are brought back to the git repository. How do I fix this?


回答1:


If I get you right, after rebasing you want to do git push -f origin instead of git pull. This rewrites the remote repos history as intended.

ATTENTION Force pushing to a shared repository potentially wipes other people's changes and should only be done after confering with everyone having access. Additionally I'd suggest to make sure you can access the discarded history of origin/master in the future (by tagging it or something similar), at least until everybody agrees the rebase worked out fine.



来源:https://stackoverflow.com/questions/23437725/removing-large-file-from-git-history

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!