Install Git LFS on Ubuntu 24.04

Install Git LFS on Ubuntu 24.04

Git LFS (Large File Storage) is an extension of Git that allows users to manage and track large files, such as high-resolution images, videos, audio files, and other large assets, without overloading the main Git repository.

This tutorial demonstrates how to install Git LFS on Ubuntu 24.04.

Prepare environment

Make sure you have installed Git in your system. You can read post how to install it.

Install Git LFS

Add the Git LFS repository:

wget -qO - https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

Install Git LFS:

sudo apt install -y git-lfs

Once the installation is complete, we can verify the Git LFS version by running:

git lfs --version

Testing Git LFS

Hugging Face repositories use Git LFS to store models and datasets. For instance, you can clone a repository by running the following command:

git clone https://huggingface.co/microsoft/resnet-50

With Git LFS installed on the system, Git will clone the repository by downloading the actual large files instead of just their references.

To verify, use the command ls -lh to check the file sizes:

ls -lh resnet-50
total 392M
-rw-rw-r-- 1 adminer adminer 2.6K Nov  3 05:59 README.md
-rw-rw-r-- 1 adminer adminer  68K Nov  3 05:59 config.json
-rw-rw-r-- 1 adminer adminer  98M Nov  3 06:00 flax_model.msgpack
-rw-rw-r-- 1 adminer adminer  98M Nov  3 06:00 model.safetensors
-rw-rw-r-- 1 adminer adminer  266 Nov  3 05:59 preprocessor_config.json
-rw-rw-r-- 1 adminer adminer  98M Nov  3 06:00 pytorch_model.bin
-rw-rw-r-- 1 adminer adminer  98M Nov  3 06:00 tf_model.h5

Uninstall Git LFS

If you wish to completely remove Git LFS, run the following command:

sudo apt purge --autoremove -y git-lfs

Remove GPG key and repository:

sudo rm -rf /etc/apt/keyrings/github_git-lfs-archive-keyring.gpg
sudo rm -rf /etc/apt/sources.list.d/github_git-lfs.list

Leave a Comment

Cancel reply

Your email address will not be published.