GitHub上传大文件_Github管理大文件lfs

GitHub不允许直接上传大文件(超过100M)的文件到远程仓库,若要想继续提交可以尝试使用大文件支持库:使用的简单步骤:

安装git-lfs

去GitHub上找到自己需要的版本

我用的是ubuntu的

sudo apt-get install git-lfs

开启lfs功能

git lfs install

添加大文件

使用 git lfs track 命令进行大文件追踪 例如git lfs track “*.png” 追踪所有后缀为png的文件

git lfs track Nessus8.14破解版/Nessus-8.14.0-es7.x86_64.rpm

查看GIT LFS管理的文件

git lfs track

或者 显示当前跟踪的文件列表

git lfs ls-files

自动生成.gitattributes

上面 执行 git lfs track ...后会自动生成 .gitattributes
如果没有生成,我们可以自己创建 .gitattributes 文件
文件内容为:

cat .gitattributes
Nessus8.14破解版/Nessus-8.14.0-es7.x86_64.rpm filter=lfs diff=lfs merge=lfs -text
Nessus8.14破解版/all-2.0.tar.gz filter=lfs diff=lfs merge=lfs -text

提交 .gitattributess配置文件

注意:要先提交配置文件,再提交大文件

 git add .gitattributes
 git commit -m "添加大文件支持"
 git push

提交 大文件

 git add Nessus8.14破解版/*
 git commit -m "添加软件件Nessus"
 git push

1、提交时可能遇到问题

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

leenhem@DESKTOP-0ACGT17:/mnt/c/workspace/code/software$ git push
Username for 'https://github.com': leenhem
Password for 'https://leenhem@github.com':
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 4 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 342.56 MiB | 25.16 MiB/s, done.
Total 10 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 0e943ab99b89439cfe86e15a06ca164ac242bda2fbe0c3e4fc156f3b8fcc24a9
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File Nessus8.14破解版/all-2.0.tar.gz is 301.99 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/leenhem/software.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/leenhem/software.git'

解决方法

先把这个.gitattributes跟踪文件提交上传到远程,再把大文件提交并上传到远程的,这个要注意顺序。

2、提交时可能遇到问题

Remote “origin” does not support the LFS locking API. Consider disabling it with:
$ git config lfs.https://github.com/leenhem/software.git/info/lfs.locksverify false
Post https://github.com/leenhem/software.git/info/lfs/locks/verify: unexpected EOF
error: failed to push some refs to ‘https://github.com/leenhem/software.git’

leenhem@DESKTOP-0ACGT17:/mnt/c/workspace/code/software1/software$ git push
Username for 'https://github.com': leenhem
Password for 'https://leenhem@github.com':
Remote "origin" does not support the LFS locking API. Consider disabling it with:
  $ git config lfs.https://github.com/leenhem/software.git/info/lfs.locksverify false
Post https://github.com/leenhem/software.git/info/lfs/locks/verify: unexpected EOF
error: failed to push some refs to 'https://github.com/leenhem/software.git'

解决方法

按照提示执行命令

git config lfs.https://github.com/leenhem/software.git/info/lfs.locksverify false

链接: 码404:GitHub上传大文件_Github管理大文件lfs

上一篇:Git lfs 使用教程(下载[clone])


下一篇:GitHub上传大文件