Storing Large Files in Git Repositories

There are some projects you may have to keep track of bulky files. For an instance the Video File you want to display in your website or the source file of a 3D animation. When you are using cloud based Git service provides like GitHub and Bitbucket they have maximum file limitations. (Read more on the comparison of free cloud based Git service provides)

Worry not! LFS to rescue. You can easily add the Git extension LFS, to manage large files you need to keep track in your repository.

Git Large File Storage (LFS) is an open source extension that can be installed into your Git client. 

Once you configure the LFS to manage your bulky file it will create a pointer file to to acts as a reference to the actual file.

Git Large File Storage flow.

The pointer file contains some unique details about the file it’s tracking like sha256 hash, unique id etc. During the push and clone of the repository the pointer file is used to keep track of the large file.

Below are the steps to install , configure and push a large file to a git repository.

1. Install the Git LFS extension to your git client

git lfs install

2. Add the large file you want the git LFS to track.

git lfs track myLargeVideo.mp4

3. Commit & Push the changes to your repository.

git add myLargeVideo.mp4
git commit -m "Using LFS to store video file reference"
git push origin master

Note: When you are using the LFS extension your large files does not stored in the same repository. Depending on the service provider a separate file server will be used to store the original file and a pointer file will be used to keep track of the file.

Cite this article as: Sam Muller, "Storing Large Files in Git Repositories," in Cyber Memos, December 5, 2019, https://cybermemos.com/developent/version-control/how-to-save-large-files-in-git-repositories/.