How to add Git LFS to a project

A step by step guide on adding git large file storage (lfs) to a project using Terminal.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 09/01/2023 at 13:05
Last Updated on 09/01/2023 at 14:30
<p>Two flowers that represent Terminal and Git side by side. Beneath them sits the text "Initialize git lfs."</p>

A step by step guide on adding git large file storage (lfs) to a project using Terminal.

SubscribeDiscover Git LFSRead Github's Setup Guide

Step One: Install Git LFS

<p>A screenshot of Terminal showing you how to install Git LFS using homebrew.</p>

Open Terminal and install Git LFS the following line:

brew install git-lfs

If you do not have homebrew, consult the git lfs install guide or install homebrew using the links below.

Read Github's Git LFS install guideHow to Install Homebrew

Step Two: Set the Current Directory

<p>A screenshot of terminal showing you how to set the current directory.</p>

In Terminal, set the current directory to the folder that holds the repository.

cd path/to/your/repository

Step Three: Track Files

<p>A screenshot of Terminal showing you how to track all the .png files.</p>

To start using git lfs you must associate it with a file, or type of file in your repository.

Track File Types

To track all file types (i.e. all pngs) use a line similar to that below.

git lfs track "*.filetype"

Track Specific Files

To track specific files, use a line similar to that below. Please note that the path is relative to the project.

git lfs track "path/to/file.filetype"

Untrack files

If something went wrong and you want to untrack files or file types, use a line similar to that below.

git lfs untrack "pattern"

Make changes outside terminal

To make changes without using Terminal, edit the .gitattributes file.

Step Four: Sync

<p>A screenshot of terminal showing you how to sync the changes and push them to your repository.</p>

Finally, sync the changes with your repository to complete the changes.

git add .; git commit -m "message"; git push origin main

Did something go wrong ?

Consult our troubleshooting Git LFS guide to resolve your problem.

Check out our Git LFS Troubleshooting Guide

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe