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

“Agile Transformation” — Know What’s Ahead…

Embrace Rapid Prototyping with Salesforce

Devops videos- 29 février 2020 | xavki

NLP in C# made easy with spaCy & Catalyst

Git Hacks — reverting a single file from a commit having multiple files.

What is Ionic Framework and Its Uses?

What is Ionic Framework

Engineering Jedi: Five(ish) Things to Prepare for with iOS 11

How to create an image out of text using Python and Glide OpenAI library ?

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

How do object and class attributes work in Python ?

Object-Oriented Programming with Python

Using Flask with MongoDB and SQLite database(33)

How to creat ASP.NET