从git历史中删除大文件? [英] Removing large file from git history?

查看:311
本文介绍了从git历史中删除大文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个远程git仓库,其中没有文件的大小限制,我们已经将300MB推入其中。然后我们意识到它,然后从存储库中删除文件。

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

  remote:error:文件目录/文件名是312.27 MB;这超出了GitHub的文件大小限制100 MB 

为了解决这个问题,我尝试了使用交互式git rebase解决方案建议在如何删除/从Git仓库中的提交历史中删除一个大文件?,但在rebase操作结束时,当我执行 git status 时,结束以下操作:

  [18:10:35] $ git status 
在分支大师
你的分支和'origin / master'有分歧,
,分别有8个和24个不同的提交。
(使用git pull将远程分支合并到你的)

如果我使用 git pull ,然后将所有已删除的更改返回到git存储库。我如何解决这个问题?

解决方案

如果我找到你的话,rebasing之后你想做 git push -f origin 而不是 git pull 。这会按照预期重写远程回购记录。



注意强制推送到共享存储库可能会抹去其他人的更改,并且只应在授予每个人都可以访问。
此外,我建议您确保将来可以访问 origin / master 的废弃历史记录(通过标记它或类似内容),至少直到大家都同意这个rebase成功了。

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?

解决方案

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.

这篇关于从git历史中删除大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆