githubgit-lfs

github keeps giving me Large file detected errors even though I added LFS support and made this file a large file


I have a 75.28MB file in my git repo, so GitHub complained and I added LFS support. That branch has now been committed to main. My other branches are now getting the LFS efforts.

Below I'm on the dev-status branch, but it's giving me the error:

% git push origin                                                                                                                       
Enumerating objects: 593, done.
Counting objects: 100% (425/425), done.
Delta compression using up to 10 threads
Compressing objects: 100% (352/352), done.
Writing objects: 100% (371/371), 27.88 MiB | 8.09 MiB/s, done.
Total 371 (delta 255), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (255/255), completed with 33 local objects.
remote: warning: See https://gh.io/lfs for more information.
remote: warning: File 0ecea93eba3e57e36581c06aca7677408e78f6b6 is 75.28 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote:
remote: Create a pull request for 'dev-status' on GitHub by visiting:
remote:      https://github.com/Plant-Tracer/webapp/pull/new/dev-status
remote:
To github.com:Plant-Tracer/webapp.git
 * [new branch]      dev-status -> dev-status
% 

Yet I clearly have lfs enabled:

% cat .gitattributes
etc/ffmpeg-6.1-amd64-static filter=lfs diff=lfs merge=lfs -text
%

Thoughts?


Solution

  • Your entire history must be uploaded to Github. Deleting a large file via git rm and replacing it with LFS does not remove it from history.

    You must replace the large file with its lfs version for all history. git lfs migrate will do that for you. However...

    In all modes, by default git lfs migrate operates only on the currently checked-out branch, and only on files (of any size and type) added in commits which do not exist on any remote. Multiple options are available to override these defaults.

    To migrate all branches and all commits, even those already pushed, add --everything. See Migrate Local History in the git-lfs-migrate docs.

    Note: instead of git push --force try git push --force-with-lease to avoid overwriting other people's changes.