Git Large File Storage (LFS) version large files on the remote git server

Git Large File Storage (LFS)

Git Large File Storage (LFS) is an open source Git extension for versioning large files that 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 GitLab, GitLab.com, GitHub.com or GitHub Enterprise.

Features

  • Large file versioning

    Version large files—even those as large as a couple GB in size—with Git.

  • More repository space

    Host more in your Git repositories. External file storage makes it easy to keep your repository at a manageable size.

  • Faster cloning and fetching
    Download less data. This means faster cloning and fetching from repositories that deal with large files.

  • Same Git workflow

    Work like you always do on Git—no need for additional commands, secondary storage systems, or toolsets.

– Same access controls and permissions

Keep the same access controls and permissions for large files as the rest of your Git repository when working with a remote host like GitHub.

Installation

Install or download the Git command line extension git-lfs.

1
2
# Mac OS X with brew.
$ brew install git-lfs

Setup

Set up Git LFS for your user account by running:

1
$ git lfs install

You only need to run this once per user account.

It will add the following to your ~/.gitconfig.

1
2
3
4
5
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f

Tracking

In each Git repository where you want to use Git LFS, select the file types you’d like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime.

1
$ git lfs track "*.psd"

Now make sure .gitattributes is tracked:

1
$ git add .gitattributes

Note that defining the file types Git LFS should track will not, by itself, convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history. To do that, use the git lfs migrate[1] command, which has a range of options designed to suit various potential use cases.

There is no step three. Just commit and push to GitHub as you normally would.

1
2
3
$ git add file.psd
$ git commit -m "Add design file"
$ git push origin master

References

[1] Git Large File Storage | Git Large File Storage (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.com or GitHub Enterprise. - https://git-lfs.github.com/

[2] Git Large File Storage (LFS) | GitLab - https://docs.gitlab.com/ee/topics/git/lfs/

[3] Migrate a Git repo into Git LFS with BFG | GitLab - https://docs.gitlab.com/ee/topics/git/lfs/migrate_to_git_lfs.html