Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to use Git for large files

Anjana Shankar


Git is not inherently suitable for storing large files like audio, video, and graphics. Github blocks any push that is greater than 100Mb to ensure performance.

Git Large File Storage is an extension that replaces the large files as text references in Git and stores the actual file on the remote server.

Install git-lfs

We can type the following commands in the terminal to install git-lfs:

curl -s | bash

apt-get install git-lfs

git lfs install

On Mac, we can replace the first two commands with:

brew install git-lfs
Terminal 1

Set up the repository

We would need to configure lfs in each Git repository where we want to use git-lfs.

git lfs track "*.psd"

We can also create and edit the .gitattributes file directly. We need to make sure that the .gitattributes file is tracked in Git.

Finally, we simply commit and push.

Note that simply tracking a file will not convert any existing files tracked in Git to lfs. We can use git lfs migrate for doing that.


Let’s add a largeFile.pdf in the GitHub repository

This repository needs to be cloned to the local machine.

Create/copy the file in the cloned repository folder on local.

git init
ls -A
git lfs track "*.pdf"
cat .gitattributes

Try out the above commands.

Terminal 1

On Github, the file would show up as follows:


The contents of the .gitattributes file can also be seen on Github.



View all Courses

Keep Exploring