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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值