Git LFS, simple tutorial

Overview

The Git LFS (Large File Storage) is a git extension, programmed in Go, which was created by developers at Atlassian and Github. This tool aims to avoid a limitation of the Git version control system, that it performs poorly when versioning large files, especially binaries. It does this by storing large files in a separate location from your repository and placing a pointer file in your repository directing to its location.

Down below, we have a list of extensions that are binary file formats:

  • Images: jpg, png, gif, bmp, tiff, psd
  • Videos: mp4, mkv, avi, mov, mpg, vob
  • Audio: mp3, aac, wav, flac, ogg, mka, wma
  • Documents: pdf, doc, xls, ppt, docx, odt
  • Archive: zip, rar, 7z, tar, iso
  • Database: mdb, accde, frm, sqlite
  • Executable: exe, dll, so, class

To use the Git LFS in our machine, first we need to install the Git LFS (in Windows we can do that using Chocolatey package manager):

choco install git-lfs

After that, we can complete the instalation using the command below:

git lfs install

How it works?

This section is based on the Atlassian Git LFS Tutorial

  1. When you add a file to your repository, Git LFS will replace the content with a pointer, and stores the file contents in a local Git LFS cache.
  2. When new commits are pushed to the server, the Git LFS files referenced by the newly commit are transferred from the local Git LFS cache to the remote Git LFS storage.
  3. When a commit that contains Git LFS pointers is checked out, they are updated with files from the local Git LFS cache, or downloaded from the remote Git LFS storage.

Using Git LFS

In Fork, we can use the Git LFS in a repository like we use GitFlow. First, we need to initialize Git LFS in the repository:

After that, we can track the files by pattern or anything else (in the image below, we’re tracking all .dll and .exe files):

The files will be replaced by new files (that use LFS) and a .gitattributes files will be created with the commands down below.

After this stage, we need to add, commit and push the files to origin branch. Thus, the file will be marked by LFS Tag, like thhis example:

Hope you guys like this simple tutorial! ❤😎

--

--

--

Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Data Structures for Dummies: Hash Tables

The designer’s guide to the OSX command prompt

Mapping sewer flow timing in ICM using SQL

Technomancer tools: Tiddlywiki

GXChain Progress Report Aug.3-Aug.9

Best Docker Container Tools and Resources

Web scraping application using python

Learn to Use Powerful SGC WebSockets WebRTC in C++ Builder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gabriel Ribeiro

Gabriel Ribeiro

Software Developer

More from Medium

My Competitive Programming Setup with VS Code

Jquery Ajax Post Request Example With Images (Python/Django)

jquery ajax post method

GitHub?…Yeah sure I know how to use that

Get Started with Django in 5 min