Unable to use lfs to store large files in repository

Sorry for the long post, but my two specific questions are in boldface in the text below.

I’m trying to learn how to use github with large (>100MB) files so I set up a test case to learn and experiment. I created a directory (named test) which contains a small text file, a large file, and a subdirectory which contains another large file. Both the large files are Photoshop files because that’s what was handy. My .gitignore file contains just the following:

# No emacs backup files anywhere
**/*~

My .gitattributes file contains the following line (because both the large files have the extension .psd):

**/*.psd filter=lfs diff=lfs merge=lfs -text

With this preamble, I initialized the repository with “git init” and then gave the command (to verify everything was correct) “git add -n -v .” This yielded the following, which is exactly what I would expect:

add '.gitattributes'
add '.gitignore'
add 'bg.psd'
add 'f1.txt'
add 'sub/bgr1.psd'

Then I repeated that command without the “-n”, and followed up with “git commit” (provided the required comment in emacs). Then I created a private repository named test in my github account, and then gave the following commands:

$ git remote add origin https://github.com/<my-username>/test.git
$ git push -u origin master

This resulted in git asking for my login credentials 3 times (why three times?), followed by:

Counting objects: 8, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (8/8), 101.11 MiB | 2.13 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0)
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 131cc4912fd2a0290cbf90e4d77c2db1
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File bg.psd is 344.81 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File sub/bgr1.psd is 148.98 MB; this exceeds GitHub's file size limit of 100.00 MB

Since I’ve specified in the .gitattributes file that files with an extension of “.psd” are large files, why would I get these errors? NOTE: I followed the instructions on this page: https://git-lfs.github.com/, and I installed lfs (in Ubuntu) with:

sudo apt-get install git-lfs

Thanks in advance.

Hi there! :wave: Welcome to the Community!

It looks like you didn’t run git lfs install in the repo before adding the files? As well as installing LFS globally, you also need to run the command in each repo you plan to use it in, so that all the relevant hooks are installed.

The errors you are seeing are the result of the files being committed to the regular Git history, rather than being swapped out for pointer files, which is what would have happened had LFS been properly installed and initialized.

You were prompted for your credentials multiple times because you need to authenticate both to the regular GitHub repository, and also to the LFS system. (I’m not certain where the third request came from?) It’s recommended that you use credential caching when using LFS to cut down on the number of authentication requests you’ll get.

You might want to use this more detailed tutorial to experiment more with LFS:

Hope that helps!

Aha – I see my error now. Since I’d already installed lfs (sudo apt . . .) I thought (mistakenly) that “git lfs install” was redundant. But I didn’t realize that “git lfs install” is installing the hooks, rather than the software itself.

Once I corrected my error, everything is working as expected – many thanks!!

1 Like