Skip to content

Git LFS

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.

Install

shell
brew install git-lfs

Usage

1、Set up Git LFS for your user account

shell
git lfs install

2、Select the file types you'd like Git LFS to manage

shell
git lfs track "*.psd"

And make sure .gitattributes is tracked:

shell
git add .gitattributes

Or you can edit the .gitattributes file directory.

NOTE

Defining the file types Git LFS should track will not convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history.

3、Commit and push as you normally would

shell
git add file.psd
git commit -m "Add design file"
git push origin main

4、Migrate existing large files in your history to use Git LFS (Optional)

shell
git lfs migrate import --include="*.psd" --everything

NOTE

This will rewrite history and change all of the Git object IDs in your resposity.

5、Confirm Git LFS managed files

shell
git lfs ls-files

6、Convert your repository back to a plain Git repository

shell
git lfs migrate export --include="*.psd" --everything

NOTE

This will rewrite history and change all of the Git object IDs in your resposity.

References