DEV Community

KENTO⚽️XR Engineer😎
KENTO⚽️XR Engineer😎

Posted on

【Unity】How to use Git LFS.

Intro

If your a file is larger than 100MB, you will need to manage it with Git LFS.

I write the way down on this article about how to use Git LFS.
Since I have many opportunities to use Unity, I will write based this on a simple Unity sample.

Environments

name version
Unity 2020.3.4f1
Fork 1.69.3.0

What is Git LFS?

Git is a distributed version control system, meaning the entire history of the repository is transferred to the client during the cloning process. For projects containing large files, particularly large files that are modified regularly, this initial clone can take a huge amount of time, as every version of every file has to be downloaded by the client. Git LFS (Large File Storage) is a Git extension developed by Atlassian, GitHub, and a few other open source contributors, that reduces the impact of large files in your repository by downloading the relevant versions of them lazily. Specifically, large files are downloaded during the checkout process rather than during cloning or fetching.

【reference source】:Git LFS

In a nutshell, it makes it easier and more convenient to work with large files on git.

And we can not manage a large file without Git LFS.
【reference source】:About large files on GitHub

Experiment without Git LFS

We tested using Fork, a client tool for using git, to push a file larger than 100MB.

It failed as expected.
Image description

How to use

I use Git for Windows, which includes Git LFS, so I'll skip the installation steps.

First, copy the path to the large file.
Image description

Next, open the console and enter the following command.

$ git lfs track [path]
Enter fullscreen mode Exit fullscreen mode

If successful, ".gitattributes" will be added and the lfs message will be written.

Image description

If you have already created commit that contains a large file, you have to enter the following command.

$ git rm --cached [path]
Enter fullscreen mode Exit fullscreen mode

Other Resources

Git Large File Storage

Top comments (0)