Git Large File Storage [LFS] 的安装与使用
- 1. An open source Git extension for versioning large files
- 2. Installing on Linux using packagecloud
- 3. Getting Started
- 4. `Error: Failed to call git rev-parse --git-dir: exit status 128`
- References
1. An open source Git extension for versioning large files
https://git-lfs.com/
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.
https://github.com/git-lfs/git-lfs
Git LFS is a command line extension and specification for managing large files with Git.
The client is written in Go, with pre-compiled binaries available for Mac, Windows, Linux, and FreeBSD.
2. Installing on Linux using packagecloud
https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md
packagecloud hosts git-lfs packages for popular Linux distributions with apt/deb and yum/rpm based package-managers.
apt/deb: sudo apt-get install git-lfs
(base) yongqiang@yongqiang:~$ sudo apt-get install git-lfs
...
Unpacking git-lfs (2.9.2-1) ...
Setting up git-lfs (2.9.2-1) ...
Processing triggers for man-db (2.9.1-1) ...
(base) yongqiang@yongqiang:~$(base) yongqiang@yongqiang:~$ git-lfs --version
git-lfs/2.9.2 (GitHub; linux amd64; go 1.13.5)
(base) yongqiang@yongqiang:~$
3. Getting Started
(1) Download and install the Git command line extension. Once downloaded and installed, set up Git LFS for your user account by running:
git lfs install
You only need to run this once per user account.
(2) In each Git repository where you want to use Git LFS, select the file types you’d like Git LFS to manage (or directly edit your .gitattributes
). You can configure additional file extensions at anytime.
git lfs track "*.psd"
Now make sure .gitattributes
is tracked:
git add .gitattributes
Note that defining the file types Git LFS should track will not, by itself, convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history. To do that, use the git lfs migrate
command, which has a range of options designed to suit various potential use cases.
(3) There is no step three. Just commit and push to GitHub as you normally would; for instance, if your current branch is named main
:
git add file.psd
git commit -m "Add design file"
git push origin main
4. Error: Failed to call git rev-parse --git-dir: exit status 128
(base) yongqiang@yongqiang:~/whisper_work$ git-lfs --version
git-lfs/2.9.2 (GitHub; linux amd64; go 1.13.5)
(base) yongqiang@yongqiang:~/whisper_work$
(base) yongqiang@yongqiang:~/whisper_work$ git lfs install
Error: Failed to call git rev-parse --git-dir: exit status 128
Git LFS initialized.
(base) yongqiang@yongqiang:~/whisper_work$
https://github.com/git-lfs/git-lfs/issues/3964
git lfs install --skip-repo
(base) yongqiang@yongqiang:~/whisper_work$ git lfs install --skip-repo
Git LFS initialized.
(base) yongqiang@yongqiang:~/whisper_work$
- 更新 Git LFS v2.10.0 以上的版本
References
[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/
[2] Git Large File Storage, https://git-lfs.com/