Large binary files are a tough problem for every version control system: every little change to a large binary file will add the complete (large) file to the repository once more. This results in huge repository sizes very quickly.
The "Large File Storage" extension for Git deals with exactly this problem.
Tracking Files with LFS
After installing LFS on your local computer once, you'll be able to "track" files (or file patterns) via LFS.
As a result, these files will not be stored in your local repository, but in a dedicated LFS cache (locally) and store (remotely). In the end, you'll have smaller local Git repositories because LFS manages data storage very efficiently - saving only the data you need on your local computer.
To tell LFS to handle a certain file, use the "track" command:
$ git lfs track "assets/design.psd"
Of course, you can also have LFS manage all files of a certain type:
$ git lfs track "*.psd"
The .gitattributes File
After executing the "track" command, you'll notice that a file named ".gitattributes" (located in the root of your repository) was changed. This is because LFS notes the files and file patterns you want to track in exactly this ".gitattributes" file.
Just like with the ".gitignore" file that you might already know, you should keep in mind that changes in ".gitattributes" should be staged and committed to the repository like any other change, too.
0 comments:
Post a Comment