由于文件过大,Git 推送命令失败[重复]

问题描述 投票:0回答:2

我提交并推送了一个大文件,但后来失败了。之后我删除了这个大文件,并在 git 中忽略它,但从那时起,不再有推送起作用了。

如何解决?

==[IDE]== Jan 17, 2017 1:25:30 AM Pushing - sip-phone
git branch
git remote -v
setting up remote: origin
git submodule status
git push [email protected]:xxxxx/sip-phone.git refs/heads/master:refs/heads/master
Resolving deltas: 100% (22/22), completed with 3 local objects.
error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
error: Trace: xxfxxxxxx73bfbfecaba
error: See http://git.io/iEPt8g for more information.
error: File tls/tb/plugin/Safari.pkg is 126.54 MB; this exceeds GitHub's file size limit of 100.00 MB

Remote Repository Updates
Branch Update : master
Old Id        : b739976f2dfc95d6c79810a66e3ec87e5ad5e12b
New Id        : e06457ec3487834e8129ac511d7f7036f2f34b5b
Result        : REJECTED_OTHER_REASON

Local Repository Updates
==[IDE]== Jan 17, 2017 1:26:51 AM Pushing - sip-phone finished.

提前致谢。

git git-push
2个回答
2
投票

需要几个步骤才能完全删除有关大文件的信息:

1。检查大文件什么时候出现在提交历史中,

git log --oneline --branches -- largefilename

然后复制最早的commit id(出现在底部)。

2。从最早的相关提交历史中删除该文件,

git filter-branch --index-filter  'git rm --ignore-unmatch --cached largefilename' -- <earliest_commit_id>^..

3.清理.git中的内容如下:

rm -Rf .git/refs/original
 rm -Rf .git/logs/
 git gc
 git prune --expire now

4。现在就可以成功推送到远程了。


0
投票

您删除了它,但仅在新的提交中,它仍然存在于旧的提交中,并且 GitHub 不允许您推送它。您需要从历史记录中完全删除该文件,而不仅仅是通过新提交删除它。如果这仅在您最近的提交之一中引入并且之后没有触及,那么使用

git rebase -i
编辑有问题的提交并从提交中删除大文件可能是最简单的。如果存在时间较长且多次更改,带有
git filter-branch
--index-filter
将是正确的选择。

© www.soinside.com 2019 - 2024. All rights reserved.