Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab push error: LFS objects are missing

I've used Git LFS for GitLab for a few months now without any problems, but it returned the following error while pushing files lately:

$ git push origin master
Git LFS: (14 of 14 files) 8.88 MB / 8.88 MB
Counting objects: 54, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (54/54), 5.42 KiB | 0 bytes/s, done.
Total 54 (delta 15), reused 0 (delta 0)
remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".
To https://gitlab.com/<gitURL>.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/<gitURL>.git'

where gitURL is my git-repository URL.

As the error suggests I tried to manually push my binary files, using git lfs push --all, which gives me the following output:

$ git lfs push --all origin master
Git LFS: (0 of 0 files, 1370 skipped) 0 B / 0 B, 1.77 GB skipped

which means by my understanding that all my local files are already successfully stored on my server.

Trying to fetch all lfs files does work fine as well:

$ git lfs fetch --all
Scanning for all objects ever referenced...
* 1446 objects found
Fetching objects...

which finishes without any errors.

Moreover checking all lfs files for consistency using git lfs fsck seems to work fine too:

$ git lfs fsck
Git LFS fsck OK

I'm starting to run out of ideas about fixing this error now. Any help would be greatly appreciated.

like image 496
Alex Avatar asked Nov 19 '17 16:11

Alex


People also ask

Why are my LFS objects missing from GitLab?

remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all". The solution was to disable Git Large File Storage (LFS) in the gitlab project settings. Settings > General > Visibility, project features, permissions > Expand > Git Large File Storage (LFS) And it is faster than the other answer.

Why are my LFS objects missing on push?

LFS objects are missing on push. GitLab checks files to detect LFS pointers on push. If LFS pointers are detected, GitLab tries to verify that those files already exist in LFS on GitLab. Verify that LFS is installed locally and consider a manual push with git lfs push --all .

Why do my push notifications fail in GitLab LFS?

Pushes then fail if you have GitLab LFS support enabled. To stop push failure, LFS support can be disabled in the Project settings, which also disables GitLab LFS value-adds (Verifying LFS objects, UI integration for LFS).

Do Git LFS objects go through HTTPS?

When SSH is set as a remote, Git LFS objects still go through HTTPS. Any Git LFS request asks for HTTPS credentials to be provided so a good Git credentials store is recommended. Git LFS always assumes HTTPS so if you have GitLab server on HTTP you must add the URL to Git configuration manually .


3 Answers

This command helped me:

git lfs ls-files -l | awk '{ print $1 }' | xargs git lfs push --object-id origin

And it is faster than the other answer.

like image 39
tlenz Avatar answered Sep 23 '22 21:09

tlenz


This happened to our repositories on GitLab when they introduced their own LFS support recently. If you want to continue to use your own LFS then the process is rather painful - you need to disable their own LFS support on each repository, but there doesn't seem to be a web option for it, you need to do it via their command line API:

  1. Install the python gitlab command line API: pip install python-gitlab
  2. Setup a private gitlab token for your account, generate it on the Access Tokens portion of your account profile.
  3. Write a configuration file out to ~/.python-gitlab.cfg:

    [global]
    default = yourrepo
    ssl_verify = true
    timeout = 20
    
    [yourrepo]
    url = https://gitlab.com/
    private_token = <your API key from the settings tab on gitlab.com>
    
  4. Grab your gitlab project id from the top of the settings web page

  5. gitlab project update --lfs-enabled false --id <Your project id>

Some of our developers reported that even this didn't work and they had to resort to sending a manual HTTP PUT request to https://gitlab.com/api/v4/projects/<Your project id>?lfs_enabled=false with a Private-Token header set to your private token. For example, with CURL:

 curl -X PUT --header "Private-Token: <private token>" -F "lfs_enabled=false" https://gitlab.com/api/v4/projects/<project id>
like image 171
mfj Avatar answered Sep 24 '22 21:09

mfj


I got this error even though (to my knowledge) I did not have any LFS objects in my gitlab repository.

remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".

The solution was to disable Git Large File Storage (LFS) in the gitlab project settings.

Settings > General > Visibility, project features, permissions > Expand > Git Large File Storage (LFS)

like image 37
mcaleaa Avatar answered Sep 24 '22 21:09

mcaleaa