Learning Git: What is Git LFS?
Learning Git: What is Git LFS?
Instead of creating a whole new file for your binary files in your repo, learn how you can use this application to pull only what you need.
Join the DZone community and get the full member experience.Join For Free
Git LFS stands for Large File Storage and is a tool many developers use to save space when working with binary files.
Watch This Quick Video or Keep Reading to Learn More!
What Is Git LFS?
In short, Git LFS is a Git extension that allows users to save space by storing binary files in a different location. Let’s dig in a bit to learn more about why you would want to use Git LFS and how it works.
Why Use Git LFS?
When working with repositories that contain audio, video, or image files (aka binary files), any changes made to those files are not tracked through Git in the same way that non-binary files are tracked.
While Git does a great job of tracking changesets in text files, changes made to binary files are tracked as an additional copy of the file.
Imagine you are working with a binary image that takes up 100MB on your repo and you make a change to that file. Git will track that change on a file that also takes up 100MB of space and will continue to do that for each change made.
If you want to do some quick math, four file changes made to a binary 100MB file would result in a total of 500MB used (100MB original file + 100MB change file + 100MB change file + 100MB change file + 100MB change file = 500MB).
Because these changes also get pushed to your remote, your remote will also grow in size, decreasing the speed in which you can clone, push, pull, or perform other operations with your repo.
How Does Git LFS Save Time?
When using Git LFS, your commits will point to a lightweight reference object instead of pointing back to the binary file (you’re actually pushing the original binary file to an LFS repo).
Now, when you clone the LFS repo or check out a branch in an LFS repo, you will only pull the version of the binary file that you need from the LFS server, saving space and time.
How Does Git LFS Work in GitKraken?
Before using Git LFS in GitKraken, you must first install Git LFS on your machine. You will also need to set up your LFS server, and if you’re just getting started, GitHub has a built-in free option available here.
Once installed, navigate to Preferences to access the LFS option.
You may then initialize LFS for an existing repo and specify the file types you need the application to track.
After you complete the initialization process, an LFS icon will appear in the toolbar, allowing you to interact with the files on your LFS server.
Where Can I View LFS Files?
All files tracked by LFS will be marked with the LFS icon in the Right Panel of GitKraken.
When you click to view the diff of such a file, you will see the SHA reference instead of your large file.
Finally, you may check the option to initialize the LFS application when you Init any repo from GitKraken.
We hope this helps explain the benefits of using a Git Large File Server and how easy it is to utilize the application in GitKraken.
Published at DZone with permission of Jonathan Silva , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.