Git LFS
— Code management and collaboration — 1 min read
- When you add a file to your repository, Git LFS replaces its contents with a pointer, and stores the file contents in a local Git LFS cache.
- When you push new commits to the server, any Git LFS files referenced by the newly pushed commits are transferred from your local Git LFS cache to the remote Git LFS store tied to your Git repository.
- When you checkout a commit that contains Git LFS pointers, they are replaced with files from your local Git LFS cache, or downloaded from the remote Git LFS store.
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.
Usage
1git lfs install2
3$ git lfs install4Updated pre-push hook.5Git LFS initialized.6
7$ git lfs track "*.ogg"8Tracking *.ogg9
10$ git lfs track11Listing tracked paths12*.stl (.gitattributes)13*.png (Assets/Sprites/.gitattributes)14*.ogg (Assets/Audio/.gitattributes)15
16$ git lfs ls-files17Check all files currently tracked by lfs189a3c7dae41 * 1.png19d61cf5835a * 2.png20158213f90f * 3.svg21
22$ git lfs untrack "1.png"23Uncheck a specific file24
25$ git add .gitattributes26$ git commit -m "add .gitattributes"
You can also add .gitatrributes template to the local repository instead of using git lfs track
1## Unity gitatrributes template ##2
3*.cs diff=csharp text4*.cginc text5*.shader text6
7*.mat merge=unityyamlmerge eol=lf8*.anim merge=unityyamlmerge eol=lf9*.unity merge=unityyamlmerge eol=lf10*.prefab merge=unityyamlmerge eol=lf11*.physicsMaterial2D merge=unityyamlmerge eol=lf12*.physicsMaterial merge=unityyamlmerge eol=lf13*.asset merge=unityyamlmerge eol=lf14*.meta merge=unityyamlmerge eol=lf15*.controller merge=unityyamlmerge eol=lf16
17## git-lfs ##18
19#Image20*.jpg filter=lfs diff=lfs merge=lfs -text21*.jpeg filter=lfs diff=lfs merge=lfs -text22*.png filter=lfs diff=lfs merge=lfs -text23*.gif filter=lfs diff=lfs merge=lfs -text24*.psd filter=lfs diff=lfs merge=lfs -text25*.ai filter=lfs diff=lfs merge=lfs -text26*.tif filter=lfs diff=lfs merge=lfs -text27
28#Audio29*.mp3 filter=lfs diff=lfs merge=lfs -text30*.wav filter=lfs diff=lfs merge=lfs -text31*.ogg filter=lfs diff=lfs merge=lfs -text32
33#Video34*.mp4 filter=lfs diff=lfs merge=lfs -text35*.mov filter=lfs diff=lfs merge=lfs -text36
37#3D Object38*.FBX filter=lfs diff=lfs merge=lfs -text39*.fbx filter=lfs diff=lfs merge=lfs -text40*.blend filter=lfs diff=lfs merge=lfs -text41*.obj filter=lfs diff=lfs merge=lfs -text42*.asset filter=lfs diff=lfs merge=lfs -text43
44#ETC45*.a filter=lfs diff=lfs merge=lfs -text46*.exr filter=lfs diff=lfs merge=lfs -text47*.tga filter=lfs diff=lfs merge=lfs -text48*.pdf filter=lfs diff=lfs merge=lfs -text49*.zip filter=lfs diff=lfs merge=lfs -text50*.dll filter=lfs diff=lfs merge=lfs -text51*.unitypackage filter=lfs diff=lfs merge=lfs -text52*.aif filter=lfs diff=lfs merge=lfs -text53*.ttf filter=lfs diff=lfs merge=lfs -text54*.rns filter=lfs diff=lfs merge=lfs -text55*.reason filter=lfs diff=lfs merge=lfs -text56*.lxo filter=lfs diff=lfs merge=lfs -text