背景:有些提交比较大的安装包文件,无法快速有效的上传到gitlab,所以这里使用gitlfs去提交大文件
用法:
-
安装gitlfs -
使用git lfs 命令提交大文件
windows安装
Git Large File Storage | Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
commit大文件
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project
$ git clone git@gitlab.infra.local:yilei/argocd-test.git
Cloning into 'argocd-test'...
remote: Enumerating objects: 115, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (78/78), done.
remote: Total 115 (delta 37), reused 45 (delta 15), pack-reused 9
Receiving objects: 100% (115/115), 17.62 KiB | 1.47 MiB/s, done.
Resolving deltas: 100% (38/38), done.
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project
$ cd argocd-test/
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project/argocd-test (master)
$ ls
README.md argocd/ helm/ kubernetes.tar.gz quickstart/
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project/argocd-test (master)
$ git lfs track kubernetes.tar.gz
Tracking "kubernetes.tar.gz"
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project/argocd-test (master)
$ git add kubernetes.tar.gz
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project/argocd-test (master)
$ git commit -m "add k8s lf"
[master f78c7de] add k8s lf
1 file changed, 3 insertions(+)
create mode 100644 kubernetes.tar.gz
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project/argocd-test (master)
$ git push
Locking support detected on remote "origin". Consider enabling it with:
$ git config lfs.https://gitlab.infra.local/yilei/argocd-test.git/info/lfs.locksverify true
Uploading LFS objects: 100% (1/1), 473 MB | 8.2 MB/s, done.
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 381 bytes | 381.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
To gitlab.infra.local:yilei/argocd-test.git
aa7cf29..f78c7de master -> master
主要命令:
# 告诉lfs需要管理的大文件
git lfs track kubernetes.tar.gz
效果:
文件末尾有一个LFS 的标识。
然后我们要想 clone 这个带有LFS 文件的仓库怎么办?
# 使用git lfs clone
git lfs clone git@gitlab.infra.local:yilei/argocd-test.git
mark@LAPTOP-VH57ARI1 MINGW64 /d/mark/project
$ git lfs clone git@gitlab.infra.local:yilei/argocd-test.git
WARNING: 'git lfs clone' is deprecated and will not be updated
with new flags from 'git clone'
'git clone' has been updated in upstream Git to have comparable
speeds to 'git lfs clone'.
Cloning into 'argocd-test'...
remote: Enumerating objects: 118, done.
remote: Counting objects: 100% (109/109), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 118 (delta 38), reused 105 (delta 34), pack-reused 9
Receiving objects: 100% (118/118), 17.94 KiB | 2.99 MiB/s, done.
Resolving deltas: 100% (39/39), done.
Downloading LFS objects: 100% (1/1), 473 MB | 21 MB/s
????????
?
|