当前位置: 首页 > 工具软件 > Git-it > 使用案例 >

git-lfs(for big files)

钱志强
2023-12-01

git-lfs(Git Large File Storage)

突破GitHub的限制,使用 git-lfs(Git Large File Storage) 支持单个文件超过100M

但是GitHub 目前 Git LFS的总存储量为1G左右,超过需要付费。(上传失败时,可以开启VPN进行上传)

1. 安装lfs

githubm.lfs

2. 安装lfs并进行git本地初始化

$ git lfs install
$ git init

2. 没有特别说明的情况下,LFS 不会处理大文件问题,因此,我们必须明确告诉 LFS 该处理哪些文件。将 FrameworkFold/XXXFramework/xxx的文件设置成大文件标示。

$ git lfs track tinyos.tar
"tinyos.tar" already supported

tinyos.tar为笔者电脑中大于100MB的文件(tinyos 镜像文件),github无法备份

3. 然后进行常规的git push操作

$ git add .
$ git commit -m "add large file"
$ git push

此后lfs传上去的大文件,pull需要使用:

$ git lfs pull

Errors

  1. Remote “origin” does not support the LFS locking API. Consider disabling it with

    $ git push -u origin main
    Remote "origin" does not support the LFS locking API. Consider disabling it with:$ git config lfs.https://github.com/Aaaazdy/docker-repository.git/info/lfs.locksverify false
    Post "https://github.com/Aaaazdy/docker-repository.git/info/lfs/locks/verify": dial tcp 192.30.255.112:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
    error: failed to push some refs to 'https://github.com/Aaaazdy/docker-repository.git'
    

    Solutions:

    git config lfs.https://github.com/Aaaazdy/docker-repository.git/info/lfs.locksverify false
    
  2. batch request: Access denied

    在最后一步push的时候

    git push -u origin develop1.0
    Remote "origin" does not support the LFS locking API. Consider disabling it with:$ git config lfs.https://git.oschina.net/harrydeng/xxx.git/info/lfs.locksverify false
    Git LFS: (0 of 1 files) 0 B / 207.25 MB                                                                                                    
    batch request: Access denied
    exec request failed on channel 0: exit status 255
    error: failed to push some refs to 'git@github.com/Aaaazdy/docker-repository.git'
    

    Solutions:

    删除 .git/hooks/pre-push 文件即可
    
 类似资料: