Cannot push a freshly migrated lfs bare repository to on-premise gitlab 13.7.1-ee

  1. We clone a big repository from gitolite as bare repository
  2. We migrate it with git lfs migrate import --everything --include=" .png, .zip"
  3. We clean the repository git reflog expire --expire=now --all && git reflog expire --expire-unreachable=now --all && git gc --prune=now --aggressive
  4. We do a git lfs install
  5. We prepare the repo for push to our test gitlab.example git remote rename origin old-origin git remote add origin “git@gitlab.example:namespace/repo.git”
  6. We push the repo git push -u origin --all git push -u origin --tags
  7. We delete the gitlab repo.git from our gitlab.example
  8. We make sure all background project destroy jobs and lfs delete jobs pass successfully and repo.git is purged from gitlab.example
  9. We create again the same project on our test gitlab.example
  10. Push fails with unclear message: git push -u origin --all
    we see the following error:

Enumerating objects: 1775221, done.
Counting objects: 100% (1775221/1775221), done.
Delta compression using up to 30 threads
Compressing objects: 100% (605123/605123), done.
Writing objects: 100% (1775221/1775221), 714.07 MiB | 9.17 MiB/s, done.
Total 1775221 (delta 1148245), reused 1774835 (delta 1147906)
remote: Resolving deltas: 100% (1148245/1148245), done.
remote: Checking connectivity: 1775221, done.
remote: GitLab: LFS objects are missing. Ensure LFS is properly set up or try a manual “git lfs push --all”.
To gitlab.example:namespace/repo.git
! [remote rejected] branch1 -> branch1 (pre-receive hook declined)


! [remote rejected] branchN -> branchN (pre-receive hook declined)
error: failed to push some refs to ‘git@gitlab.example:namespace/repo.git’

We investigated server logs and also tried push command with GIT_CURL_VERBOSE=1 and GIT_TRANSFER_TRACE=1 in addition to GIT_TRACE=1, but this did not help in identifying the root cause.

it is really strange that the first time you can push your repository, then if you want to delete it on your gitlab instance and push it again, it fails.

Your help and tips are welcome.

1 Like

I think we found the issue. It has nothing to do with gitlab. When you push a bare repository, then in your repo.git/config file you have all your already pushed branches and origin.
I guess these are called: Refspecs

A refspec maps a branch in the local repository to a branch in a remote repository.

Because of these maps, gitlab pre-receive will not let you push them again. You have to delete them if you want to push the same repository again, being it a bare one.

IMPORTANT: Also delete .git/lfs/cache and .git/refs/remotes