[原]Git 如何上传超过100M的文件

陈苏扬 18/07/19 12:23:54

首先这是我在Git上传我电子书的时候出现的问题。
BTW, 推荐一下电子书放在GitHub很方便

remote: hooks/pre-receive.rb:47:in `’
remote: warning: YOUR-BIG-FILE is 53.66 MB; this is larger than GitHub’s recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 38bb16b8e8e0162f34fdc8517439dab5
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File YOUR-GIANT-FILE is 108.53 MB; this exceeds GitHub’s file size limit of 100.00 MB
To github.com:he1l0world/Book.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ‘git@github.com:he1l0world/Book.git’

如果git上传超过50M文件就会有警告,超过100M就会出现错误
警告是没有关系,但是错误就有问题了。

先不要紧张,先运行一下命令:

    git rm --cached YOR-GIANT-FILE
    git commit --amend -CHEAD

相当于在本地领先远程仓库的cache中删除掉那个需要上传的大文件。
然后在运行git push 就可以成功把那些可以上传到GitHub的文件上传上去了.

那么剩下的大文件怎么办?

Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

正如这个提示所说,需要使用lfs来管理大文件.

作者:helloworld19970916 发表于 2018/07/19 12:23:54 原文链接 https://blog.csdn.net/helloworld19970916/article/details/81113204
阅读:194