Hi Folks,
Yes! I'm back with an interesting blog Git LFS
- An file storage system by git (basically to store large files above 100Mb)
A small back story How I came to know about this!
Recently my colleague asked me Have you ever worked in git Lfs ?
I just ignored him like this and get back to my work
Lately, my Manager told us to push changes we were working on for a month(it includes 500Mb of CSV and txt files) when we try to Push it to the remote
git tell us this
Yes! it throws the error Files with larger size should be tracked through LFS
,
it almost spoiled our holiday eve!!
After spending almost a day, we figured out what is Git LFS and how to push the files!!!!
Here are some Steps to start with Git LFS and some important points so that it won't spoils Your Holiday eve
What is Git LFS?
Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git while storing the file contents on a remote server
OK, Enough is Enough!
Let's Push Files!
Before getting started we need to install git LFS!
if you are a Mac user use
brew install git-lfs
for other os platforms please refer this
In my case, I gonna initiate new repo and some dummy files with 200Mb size
Now let's add the 200Mb into LFS
I assume you know basic git actions(add, commit,push)
Step-1: This command will set up the Git LFS in your current repo
git lfs install
Step-2: We need to tell git which type of files or which files needed to be tracked to LFS. The below command will create
.gitattributes
file contains a list of tracked files
git lfs track "*.csv"
For example:
if You are working in psd files and need to add all the psd files in LFS means you will give a pattern like "*.psd"
OR
if you need to add all the file under some folder You can give like path/folder_name/**
this will add all the files under the path
Step-3: Now add the .gitattributes and commit it as we do before
git add .
git commit -m "initial commit"
This will add all the changed files to the stage and commit those!
Step -4 : Make sure that all Your files are tracked in LFS use the below command to see the list of tracked files
git lfs ls-files
Step -5 : Let's push use the command to push the large file First
git lfs push --all origin <branch>
Then regular push
git push origin
Tada, it's all done!
Points to remember!
- Make sure the file format is correct and not corrupted
- Files above 100 MB should be added via Git LFS below that we can add through regular git actions
Thanks, @iamadhee (Lol! he is the colleague I ignored)
Thanks! folks Thanks for reading
Let me know your experience in comment section after using git LFS and the struggles you faced, I will try to post the fix :)
Top comments (0)