DEV Community

Cover image for Git LFS(Large File Storage)_How to commit files over 100MB to Github?
Emma Ham
Emma Ham

Posted on

Git LFS(Large File Storage)_How to commit files over 100MB to Github?

As we are working on a few static websites which might include portfolios, personal gallery websites etc, we have to sometimes deal with storage problems when it comes to version controlling through git, especially for videos and high quality pictures. The warning message below is what I got couple of days ago on a process of committing a file which included a video over 100MB.

Alt Text

So basically, what it says is to avoid committing these files or use Git LFS to store large files on github.
hold on a minute, what is git LFS?

Firstly, What is LFS ?

LFS stands for Large File Storage which is an open source extension provided by git for versioning large files.
In this post, I would like to talk about basic steps that you can take to use LFS properly and easily.

Secondly, Ok, how to use LFS ?

Click here to read more documentations.
Check the latest released version

First of all, Let's make sure we download the recent version of LFS according to the operating systems.

After downloading the LFS file source loacally, then we can go to our project directory file and execute the following lines.

Alt Text

If you are done intalling lfs for the repository then we need to specify the type of file which will be taken and tracked by lfs.
In this case, I am trying to upload this video file which is "mp4" format. I would like to execute the following line.

Alt Text

Of course, depending on your file format it could be something like these,
Alt Text

Alright! We are almost there, after specifying the troublesome files, then you will be able to notice some changes in the gitattribute file as well.
Alt Text
Cool, then let's go ahead and push the new changes to the github and see what happens!
If you are using github desktop, it can't be easier! You can simply click the "commit to master" button. Otherwise, you can use the lines below in your terminal as well.
Alt Text

Congratulations! Now your file is being managed by github lfs!

Lastly, How do I check if a file is managed by LFS properly?

If you want to double check whether your files are being managed git lfs properly and whether you are missing out on something, you can also check the list of all the files.

Alt Text

Summing up

Today, we have covered really easy way to deal with larger files on git. It would be really useful when it comes to manage the project workflow on github because sometimes, server storage can be pain in the neck in many ways and this knowledge of lfs can be quite helpful to avoid those problems!

Top comments (0)