Smaller Git Repo Size Using Git LFS<br> (🤔 Xcode Assets)

Smaller Git Repo Size Using Git LFS
(🤔 Xcode Assets)


If you want to see a comparison of Git with and without Git LFS, see this section below.

Have you ever gone to clone a repository (repo), and ended up just sitting there staring at the slow moving percentage…😶?

Yeah, me too — this may help!

Often times with a project, like with Xcode projects, we check assets into Git so that our app has immediate access to those files (images, videos, audio files, etc.). Over time, changes to those assets may end up bloating your repo’s size1 😅. When this happens, Git operations like cloning can take an unfortunate amount of time…

Luckily, there is a Git extension called Git Large File Storage (LFS) to help manage your large files (without changing your Git workflow 😁), which means:

1. Git is less effective at compressing binary files, and therefore ends up storing near duplicates of those files. Read more.

Getting Started with Git Large File Storage (LFS)

There are different ways to install Git LFS, but if you are on a Mac: brew install git-lfs

Setup is pretty straight forward. Do the following to add files or folders to Git LFS:

Don’t forget to make sure that installing Git LFS is part of your setup README for project :).
See the first bullet under considerations below for more details.

That’s it 🎊 — Go about your normal Git workflow like before, and the marked files will now be managed by Git LFS!

Existing Files - For The Maximum Benefit

Caution: The below steps result in a destructive git repo operation, and should be done carefully After performing the below steps, all members of your team will need to delete their local repos and re-clone the project repo. This is because their existing local repos will no longer be compatible with the newly force pushed master.

For an existing repo, you will get the biggest gain from using Git LFS by retroactively applying Git LFS to files and folders. Here is how to integrate Git LFS as if you have been using it since the beginning of your project.

For setup, do the same steps as before, but for files that are already being tracked in Git:

Comparison of Git with (and without) Git LFS

As an example I created an example project ( to compare Git with and without Git LFS.

The result was that cloning the project took close to half the time (~15s vs ~30s) when directly cloning the branch using Git LFS — and this is for a small example project. Imagine the potential impact for more mature projects with lots of file changes of this nature!!

To try this yourself:

You can also see the difference Git LFS makes in the Git repo size here:

A comparison of repo size between regular git and git lfs


Thank you for reading!

Feel free to reach out on Twitter — cheers!

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora