gitlab LFS使用
1.相关文档
配置lfs官方文档: GitLab Git Large File Storage (LFS) Administration | GitLab
在git中使用lfs:Git Large File Storage (LFS) | GitLab
2.在gitlab开启lfs功能
开启lfs包括两步:
指明存储,是本地存储的话需要指明存储路径,对象存储参考:GitLab Git Large File Storage (LFS) Administration | GitLab
vim /etc/gitlab/gitlab.rb 在配置文件中开启
gitlab_rails['lfs_enabled'] = true
gitlab-ctl reconfigure
3.在git中使用lfs
# clone需要使用lfs的仓库
git clone https://gitlab.example.com/test/lfs-test.git
cd lfs-test/
# 在仓库中安装lfs插件
git lfs install
#设置lfs 文件后缀名
git lfs track "*.iso"
将大文件复制到仓库中并push到远程仓库
cp ~/tmp/debian.iso ./ # copy a large file into the current directory
git add . # add the large file to the project
git commit -am "Added Debian iso" # commit the file meta data
git push origin main
4.git lfs使用http
Gitlab lfs 默认情况下都是使用的https,如果你的gitlab server是http的,需要手动指定http地址,否则会无法成功push lfs对象。
需要手动修改lfs的url,命令示例:
git config --add lfs.url "http://gitlab.example.com/group/project.git/info/lfs"
实例:
域名:gitlab.example.com,组名:test,项目名:lfs-test1
git config --add lfs.url "http://gitlab.example.com/test/lfs-test1.git/info/lfs"
如果不想认证,可以认证信息加到url中:
http://[user]:[password]@gitlab.example.com/test/lfs-test1.git/info/lfs