Read Anthropic’s case study about Graphite Reviewer

How to install Git LFS on Ubuntu

Kenny DuMez
Kenny DuMez
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Git Large File Storage (LFS) is an extension for Git that allows you to efficiently handle large files and binary data within your repositories. This guide provides detailed steps on how to install Git LFS on an Ubuntu system, ensuring that you can manage large assets without overloading your repository's history.

Git 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, GitLab, or Bitbucket.

Here’s a step-by-step guide on how to install Git LFS on an Ubuntu system.

Before installing Git LFS, ensure that Git is installed on your system. You can install Git using the following command:

Terminal
sudo apt-get update
sudo apt-get install git

Git LFS packages are included in the default repositories of newer versions of Ubuntu. You can install it directly using apt-get:

Terminal
sudo apt-get install git-lfs

After installation, you need to set up Git LFS for your user account. This is done using the git lfs install command:

Terminal
git lfs install

This command needs to be run once per user account. It sets up the necessary hooks in your Git configuration that will allow LFS to manage large files.

Once Git LFS is installed and initialized, you can configure it to track large files within specific repositories. Navigate to your repository directory and specify the file types you want to track with Git LFS:

Terminal
cd /path/to/your/repository
git lfs track "*.psd"

Replace "*.psd" with the appropriate file extension, for example, *.mp4 for video files or *.zip for archives. This command adds the specified patterns to a .gitattributes file in your repository.

After setting up file tracking, make sure to add the .gitattributes file and commit it:

Terminal
git add .gitattributes
git commit -m "Configure Git LFS tracking"

With Git LFS configured, you can continue to use Git commands as you normally would. Large files tracked by LFS will be handled automatically:

Terminal
git add large_file.psd
git commit -m "Add a large Photoshop file"
git push

When you push to a remote server, Git LFS will transfer the large files to the server's LFS cache, keeping your repository efficient and fast.

For further reading see the official Git LFS documentation.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2