Git强制推送给github,因为大文件被删除而不再被追踪 [英] Git force push to github rejected for large file that is deleted and no longer tracked

查看:750
本文介绍了Git强制推送给github,因为大文件被删除而不再被追踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对我的本地副本进行了许多新的更改,这些更改与我的本地副本有冲突我的github回购(但我的本地副本是正确的,我想只覆盖远程回购)。本地和远程拷贝已经分离了2次和3次提交。



我也偶然在我的本地提交中添加了一些非常大的csv文件,现在我无法使用推送到远程仓库git push - f 因为github拒绝大文件。



现在我删除了这些文件,并使用 git rm --cachedfilename.csv git commit --amend -CHEAD 并且它们不再处于提交状态,据我所知可以从 git ls-files |但是当我尝试使用 git push -f 时, code>现在不再被跟踪,github仍然检测到它们并拒绝我的推送,因为它们太大,尽管它们不再在文件系统或提交中。



如何推送本地副本来覆盖远程并获得推动力,以实现我不再拥有大型文件?



感谢您提供任何和所有的git建议......对于一个新手来说可能有点混乱。

听起来像你已经提交了大文件,然后做了另一个提交,删除大文件。这意味着大文件仍然处于一个或多个较早的提交中。当你推送到GitHub时,你会推送整个存储库,并提交所有提交(包括任何具有大文件的提交)。由于大文件,GitHub实际上拒绝了其中一个较旧的提交。



你无法看到带有 git ls-files 的文件的原因是它只列出了当前索引(最后一次提交,并且将改变你即将提交的内容)和工作树(磁盘上文件的当前状态),而不是存储库历史记录中的所有文件。



要解决这个问题,您可以按照如何从Git仓库中的提交历史中删除/删除大文件?。这样你就可以像从未提交过这个文件一样。


So I'm fairly new to git and I've gotten in a bit of a pickle.

I have many new changes to my local copy that conflict with my github repo (however my local copy is correct and I'd like to just overwrite the remote repo). The local and remote copy have diverged by 2 and 3 commits.

I also accidentally added a few very large csv files to my local commit and now I am unable to push to the remote repo with git push -f because github rejects the large files.

Now I deleted the files and removed them from the commit with git rm --cached "filename.csv" and git commit --amend -CHEAD and they are no longer in the commit as far as I can tell from git ls-files | grep "*.csv" which returns blank.

However when I try to use git push -f now after they are no longer tracked, github still detects them and rejects my push because they are too large although they are no longer on the filesystem or in the commit.

How can I push the local copy to overwrite the remote and get the push to realize I no longer have the large files?

Thanks in advance for any and all git advice... it can be a bit confusing for a newbie.

解决方案

Sounds like you have committed the large file, then made another commit that deletes the large file. That means that the large file is still in one or more earlier commits. When you push to GitHub, you're pushing the whole repository, with all commits (including any that have the large file). GitHub is actually rejecting one of the older commits because of the large file.

The reason you can't see the file with git ls-files is that it only lists the files in the current index (the last commit, and changes your're about to commit) and working tree (the current state of the files on disk), not all files in the repository's history.

To fix the problem, you can follow the steps on How to remove/delete a large file from commit history in Git repository?. That way you can make it as though you never committed the file.

这篇关于Git强制推送给github,因为大文件被删除而不再被追踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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