Git LFS 上传大于100MB文件H-T-U

前言

由于百度并没有找到中文版很好的教程,所以自己搞了一遍流程,结果遇到坑,原因是framework文件特殊性,本质是一个文件夹,解决看下文:

Get Start

Git LFS的官方网址在这里: https://git-lfs.github.com/
下载mac版本 解压如下图:

Git LFS 上传大于100MB文件H-T-U_第1张图片

localhost:Desktop dragon$ cd /Users/dragon/Downloads/git-lfs-2.2.1
localhost:git-lfs-2.2.1 dragon$ ls -l
total 15824
-rw-r--r--@ 1 dragon  staff    34163  7 11 04:11 
CHANGELOG.md
-rw-r--r--@ 1 dragon  staff     5156  7 11 04:11    
README.md
-rwxr-xr-x@ 1 dragon  staff  8049380  7 11 04:11 git-lfs
-rwxr-xr-x@ 1 dragon  staff      389  7 11 04:11 install.sh
localhost:git-lfs-2.2.1 dragon$ sudo ./install.sh 
Password:
Git LFS initialized.
注册成功
localhost:Desktop dragon$ git lfs clone https://github.com/DragonMichael/AwkwardChat.git
Git LFS 上传大于100MB文件H-T-U_第2张图片
将大文件拖入本地仓库

继续执行如下命令:

localhost:AwkwardChat dragon$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add ..." to include in what will be committed)

Hyphenate.framework/

nothing added to commit but untracked files present (use "git add" to track)
追加framework所有文件到LFS仓库
localhost:AwkwardChat dragon$ git lfs track "*.framework"
"*.framework" already supported
localhost:AwkwardChat dragon$ git lfs track "*.framework/*"
Tracking "*.framework/*"
提交git仓库
localhost:AwkwardChat dragon$ git add .
localhost:AwkwardChat dragon$ git commit -m "Add framework than 100MB file"
localhost:AwkwardChat dragon$ git push origin master
Git LFS: (2 of 2 files) 131.73 MB / 131.73 MB                                                      
To https://github.com/DragonMichael/AwkwardChat.git
提交成功!!!
如果再次提交LFS 就会跳过上传步骤
localhost:AwkwardChat dragon$ git push origin master
Git LFS: (0 of 0 files, 2 skipped) 0 B / 0 B, 131.73 MB skipped  
查询LFS仓库文件
localhost:AwkwardChat dragon$ git lfs ls-files
8334c37062 * Hyphenate.framework/Hyphenate
2a86179cb2 * Hyphenate.framework/Info.plist

重新克隆项目结果如下:可能会慢一点

Git LFS 上传大于100MB文件H-T-U_第3张图片

可见下载下来的framework一个文件都不少,美滋滋~~


Git LFS 上传大于100MB文件H-T-U_第4张图片

问题解决

本次遇到的坑是 .framework 是文件夹 所以track失败,如下图: 所以要加上这句git lfs track "*.framework/*", 把文件夹的内容也要track,下面的报错就解决了, 如有其它文件点击github 官网issues搜索结果

Git LFS 上传大于100MB文件H-T-U_第5张图片

下面是git lfs 命令集合

Commands

Like Git, Git LFS commands are separated into high level ("porcelain")
commands and low level ("plumbing") commands.

High level commands

  • git lfs env:
    Display the Git LFS environment.
  • git lfs checkout:
    Populate working copy with real content from Git LFS files.
  • git lfs clone:
    Efficiently clone a Git LFS-enabled repository.
  • git lfs fetch:
    Download git LFS files from a remote.
  • git lfs fsck:
    Check GIT LFS files for consistency.
  • git lfs install:
    Install Git LFS configuration.
  • git lfs lock:
    Set a file as "locked" on the Git LFS server.
  • git lfs locks:
    List currently "locked" files from the Git LFS server.
  • git lfs logs:
    Show errors from the git-lfs command.
  • git lfs ls-files:
    Show information about Git LFS files in the index and working tree.
  • git lfs migrate:
    Migrate history to or from git-lfs
  • git lfs pull:
    Fetch LFS changes from the remote & checkout any required working tree files.
  • git lfs push:
    Push queued large files to the Git LFS endpoint.
  • git lfs status:
    Show the status of Git LFS files in the working tree.
  • git lfs track:
    View or add Git LFS paths to Git attributes.
  • git lfs unlock:
    Remove "locked" setting for a file on the Git LFS server.
  • git lfs untrack:
    Remove Git LFS paths from Git Attributes.
  • git lfs update:
    Update Git hooks for the current Git repository.
  • git lfs version:
    Report the version number.

Low level commands

  • git lfs clean:
    Git clean filter that converts large files to pointers.
  • git lfs pointer:
    Build and compare pointers.
  • git lfs pre-push:
    Git pre-push hook implementation.
  • git lfs smudge:
    Git smudge filter that converts pointer in blobs to the actual content.

你可能感兴趣的:(Git LFS 上传大于100MB文件H-T-U)