Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

Handling Large Binary Files with LFS

Large binary files are a tough problem for every version control system: every little change to a large binary file will add the complete (large) file to the repository once more. This results in huge repository sizes very quickly.

The "Large File Storage" extension for Git deals with exactly this problem.

Tracking Files with LFS

After installing LFS on your local computer once, you'll be able to "track" files (or file patterns) via LFS.

As a result, these files will not be stored in your local repository, but in a dedicated LFS cache (locally) and store (remotely). In the end, you'll have smaller local Git repositories because LFS manages data storage very efficiently - saving only the data you need on your local computer.

To tell LFS to handle a certain file, use the "track" command:

$ git lfs track "assets/design.psd"

Of course, you can also have LFS manage all files of a certain type:

$ git lfs track "*.psd"

The .gitattributes File

After executing the "track" command, you'll notice that a file named ".gitattributes" (located in the root of your repository) was changed. This is because LFS notes the files and file patterns you want to track in exactly this ".gitattributes" file.

Just like with the ".gitignore" file that you might already know, you should keep in mind that changes in ".gitattributes" should be staged and committed to the repository like any other change, too.


Tip

Working with LFS in Tower

In case you are using the Tower Git client, you can work with Git LFS very easily: simply right-click a file in the _Working Copy_ view and choose from the various options in the "LFS" submenu.


Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.