Install Git LFS on Ubuntu 22.04

1. Introduction to the application scenarios and operating mechanism of Git LFS

1.1 Git LFS application scenarios

Git LFS (Large File Storage, large file storage) is a Git extension that can manage the download process of large files in Github projects. Git LFS has a wide range of application scenarios. Here are just two simple scenarios that I actually encountered:

  • (1) When doing machine learning or deep learning, it is always encountered that the model is too large to accommodate the GitHub warehouse.
  • (2) The number of training data sets is very large, and the GitHub warehouse can only store part of the data sets. For example, as shown in the figure below, there are actually 9,000 files microsoft/AEC-Challengein one of the data sets in the warehouse .wav, but only 1,000 files can be displayed in the GitHub warehouse. strip.

✨In addition, if we do not install Git LFS in the system, when cloning a warehouse like the one above that stores a large number of data sets , althoughmicrosoft/AEC-Challenge all the files in the project can be copied normally, the files cloned locally are empty files , there will be a BUG when reading the file.echo_fileid_0.wav.wav

1.2 Introduction to Git LFS operating mechanism

Since the client uses Git for project management, it will download each file version in the warehouse, so for projects that contain large files and often modify these large files, it takes a lot of time to use Git for initial cloning. At this point, Git LFS plays a role. Git LFS (Large File Storage) reduces the impact of large files in the warehouse by downloading the relevant versions of large files with delay.

Specifically, large files will checkoutonly be downloaded during the process, and the download task will not be performed during clonethe or fetchprocess. For the detailed operation mechanism of Git LFS, please refer to the official documentation of Git LFS .

2. Installation of Git LFS

  • Add GIT LFS third-party software installation source in Ubuntu22.04 system
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

The execution result is shown in the figure below:

As shown in the figure below, /etc/apt/sources.list.d/there are more github_git-lfs.listfiles in the directory:

github_git-lfs.listThe contents of the file are shown in the following figure:

  • The command to install Git LFS is as follows:
sudo apt isntall git-lfs

The installation result is shown in the figure below,

  • Command to view configuration information of Git LFS installation
git lfs env

If the content in the red box as shown in the following figure appears, it means that the installation is successful:

.wavAt this point, I will solve the problem of why the downloaded file is an empty file at the beginning . Although it is still normal, it is different git clone Github上包含大文件的仓库from a simple tool:Git

  • As shown in the figure below, it will appear when using git clonethe warehouse on Github 过滤内容这一项. This process is to download large files in the project warehouse:
  • Due to the installation Git LFS, when cloning the warehouse on Github, the related and related files .gitare automatically created in the project , and large files are cached in these files:Git LFSlfs/objectslfs/tmp

Guess you like

Origin blog.csdn.net/weixin_37926734/article/details/126851314