Skip to main content
Large File Support for Git
Toshi Dávila avatar
Written by Toshi Dávila
Updated today

Distributed version control systems like Git enable you to have new and powerful workflows, but they aren't always practical for versioning large files. Git Large File Support (LFS) is an improved way to integrate large binary files such as audio samples, datasets, graphics, and videos into your Git workflow. 

Assembla supports Git LFS over SSH and HTTPS protocols. 

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.

Git LFS uses reference pointers within small text files to point to large files stored on the Assembla servers, or on your own servers for our on-premise offering. You can call large files such as high resolution images and videos, audio files, and assets from a remote server. This feature allows Git users to bypass the size restrictions previously given for repositories. Note that the general recommendation is to not allow Git repositories larger than 1GB in order to preserve performance and decrease the chance of performance issues.

Git LFS is easy to download and configure, works on all major platforms, and is open sourced under the MIT license. Versioning video files, images and even microchip designs allows teams to work collaboratively to version any type of large file efficiently and reliably.

Game developers, graphic designers, mobile app developers, and anyone else building software requiring large files can use Assembla to version all of their assets.

Using Git LFS

Your first step to using Git LFS is to install a recent version of git, and then install git-lfs. See git-lfs for more information about Git LFS installation.

Creating a repo

Use the following steps to create a sample repository.

git init .

Let's create some more files.

touch > foo.txt && touch bar.txt && 
git add foo.txt bar.txt

For this example are going to make sure  *.largefiles files are managed by the LFS side of Git. The first step is to tell Git how to track these files. Tracking means that in subsequent commits, these files will then be LFS files. This is done by setting a track pattern, using the git lfs track command.

git lfs track '*.largefiles'

This command tells git-lfs to track all files matching the *.largefiles pattern. 

To see a list of all patterns currently being tracked by git-lfs, run git lfs track with no arguments:

Listing tracked paths
    *.largefiles (.gitattributes)

To see the list of files being tracked by git-lfs, run git lfs ls-files. The list is currently empty because technically the file isn't an lfs object until after you add and commit it, which is our next step.

Add .gitattributes to your Git repository. git lfs track stores the tracked files patterns in .gitattributes. This way when the repo is cloned, the track files patterns are preserved. Be sure to include some *.largefiles.

git add .gitattributes "*.largefiles"
touch testing.largefiles && git add testing.largefiles
git commit -m "testing.largefiles"

Now your git status should look like this:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   .gitattributes
        new file:   bar.txt
        new file:   testing.largefiles
        new file:   foo.txt

Finally, commit the new files.

git commit -m "Added files"

Now, when you run git lfs ls-files, you will see the list of tracked files.

f05131d24d * testing.largefiles

Working with repos and cloning

Once git-lfs is installed, you can clone an lfs repo by running a normal git clone command.

git clone git@git.assembla.com:myrepo.git

You can use git push and git pull and various other commands which are optimized to get information quickly. 

Understanding the LFS location

When using a Git server that supports lfs, the lfs url defaults upon clone/adding a remote. However, sometimes the LFS server and Git server are two separate services.

To see the lfs url, run git lfs env.

Using credentials

Assembla supports Git and https transparently so there is no need to change your workflow.

Adding git-lfs to a pre-existing repository

This is an advanced topic. Although it is possible using Git commands, it is not recommended without a migrator.

Migrating existing repository data to LFS using git-lfs-migrate

  1. Install Java 1.8 or later.

  2. Download the latest binaries from here.

  3. Do a mirror clone of the repository to rewrite: git clone --mirror git@github.com:bozaro/git-lfs-migrate.git 

  4. Rewrite e.g. all *.mp4 video files in the repository:

        java -jar git-lfs-migrate.jar \
          -s git-lfs-migrate.git \
          -d git-lfs-migrate-converted.git \
          -g git@github.com:bozaro/git-lfs-migrate-converted.git \
          "*.mp4"
  5. Push the converted repository as a new repository:

    cd git-lfs-migrate-converted.git
    git fsck
    git push --mirror git@github.com:bozaro/git-lfs-migrate-converted.git


Have questions? Email us at support@assembla.com

Did this answer your question?