由于我已经删除的大文件,无法推送到 GitHub [英] Can't push to GitHub because of large file which I already deleted

查看:29
本文介绍了由于我已经删除的大文件,无法推送到 GitHub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有

  1. 空的 GitHub 存储库
  2. SSH 服务器存储库(主要)
  3. 本地仓库

SSH 服务器存储库是最新的存储库(生产站点),所以我从那里复制了一个 Git 到本地.然后我尝试对 GitHub 执行 git push.

SSH server repo was the most up-to-date repo (production site) so I did a Git clone from there to local. I then tried to do a git push to GitHub.

一切正常,但后来它说 filename.gz 对于 GitHub 来说太大了.我不需要这个文件,所以我运行了几个 Git 命令从 Git 缓存中删除它,然后推送回 SSH 服务器.

Everything went OK but then it said something about filename.gz being too large for GitHub. I didn't need this file so I ran several Git commands to get rid of it from Git cache then pushed back to SSH server.

我在本地没有看到大文件,但它仍然在 SSH 服务器上,即使 git diff 什么都不返回并且 git push 返回一切都是最新的" - 即使文件当我尝试推送到 GitHub 时在本地存储库中不可见我仍然收到错误

I don't see the large file locally but it's still on SSH server even though git diff returns nothing and git push returns "Everything is up-to-date" - And even though the file is not visible in local repo when I try to push to GitHub I still get error about it

远程:错误:文件 fpss.tar.gz 为 135.17 MB;这超出了 GitHub 的 100 MB 文件大小限制

remote: error: File fpss.tar.gz is 135.17 MB; this exceeds GitHub's file size limit of 100 MB

我按照解决问题"下的步骤在 GitHub 帮助中列出 所以不应该够了吗?

I followed steps under "fixing the problem" listed on GitHub help so shouldn't that have been enough?

当文件不在本地或不在 git status/diff/push 中时,它如何仍在以太坊中?

How is the file still in the ether when it's not local or listed in git status/diff/push?

推荐答案

您可以使用

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

这将删除该文件历史记录中的所有内容.问题是该文件存在于历史记录中.

This will delete everything in the history of that file. The problem is that the file is present in the history.

此命令会更改提交的哈希值,这可能是一个真正的问题,尤其是在共享存储库上.不应该在不了解后果的情况下进行.

This command changes the hashes of your commits which can be a real problem, especially on shared repositories. It should not be performed without understanding the consequences.

这篇关于由于我已经删除的大文件,无法推送到 GitHub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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