📅 2016-Oct-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ git, lfs ⬩ 📚 Archive
Git repositories and its hosts like Github have limits on the file size of what can be stored there. While the file size is not really an issue for text files, it becomes a problem if you are trying to use Git to store large binary files. This is usually the case for executable files or libraries, video game assets or deep learning models. Large File Storage (LFS) is an extension to Git that can help you to handle large files. For the rest of this post, we need to assume that your Git server or host (like Github) supports LFS.
$ sudo apt install git-lfs
$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash $ sudo apt install git-lfs
$ git clone https://github.com/joe/foobar
However, note that this will download all the large files in their full size. For a large repository, this will take a long time and you need to make sure you have the space to hold the entire repository of files.
Set an environment variable to skip smudge filter and then clone:
$ GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/joe/foobar
An alternative is to use a git config that does the same:
$ git config --global filter.lfs.smudge "git-lfs smudge --skip" $ git clone https://github.com/joe/foobar
$ git lfs fetch $ git lfs checkout foobar.bin
$ git lfs fetch --include foobar.bin $ git lfs checkout foobar.bin
$ git lfs pull --include foobar.bin
$ git lfs pointer --file foobar.bin > foobar.bin.pf $ rm foobar.bin $ mv foobar.bin.pf foobar.bin $ git add foobar.bin
To view which large files are modified or not added to the repository:
$ git lfs status
$ git lfs track foobar-large-file $ git lfs track *.large-file-ext
$ git lfs track
.gitattributesand large files and create a commit:
$ git add .gitattributes $ git add foobar-large-file $ git add *.large-file-ext $ git commit -m "Add large files"
$ git push remote-name
Tried with: Git 2.17.1 and Ubuntu 18.04