I'd like to migrate some *.png
files to LFS but I'm having the following error when I git push --force
after the migration:
-bash-4.1$ git push --force
Locking support detected on remote "origin". Consider enabling it with:
$ git config lfs.https://gitlab.melexis.com/msde-bvx/msenv-90421.git/info/lfs.locksverify true Uploading LFS objects: 100% (713/713), 711 MB | 0 B/s, done
Counting objects: 23191, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (8846/8846), done.
remote: fatal: pack exceeds maximum allowed size
error: failed to push some refs to '[email protected]:msde-bvx/msenv-90421.git'
The command I've run to migrate the files looks like this:
git lfs migrate import --include="*.png" --include-ref=refs/heads/some-branch
and I get the necessary filters activated in .gitattributes
-bash-4.1$ cat .gitattributes
.gitignore export-ignore
.gitlab-ci.yml export-ignore
.gitmodules export-ignore
.gitattributes export-ignore
*.png filter=lfs diff=lfs merge=lfs -text
Any idea whether I can do something about it? What I'm worried about is that I've rewrote my history locally, so I cannot really move on with this and I should clone back the repo if I want to use it (which is quite a pain on our large repos).
Hey,
This is a message from your GitLab instance that the pack you've pushed is too large. Since you're rewriting history, many of the objects that the remote and local sides shared are no longer in common, and they must be sent again. GitLab provides an option to limit the size of the packs received, and you've hit that limit.
If your branch has a long history, you can try pushing a smaller number of commits at a time (say, 2000) with something like this:
git rev-list --reverse master | ruby -ne 'i ||= 0; i += 1; puts $_ if i % 2000 == 0' | xargs -I{} git push origin +{}:refs/heads/master
That will walk through the history of master
, pushing objects 2000 at a time. (You can, of course, substitute a different branch in both places if you like.) When that's done, you should be able to push master
one final time, and things should be up to date. If 2000 is too many and you hit the problem again, you can adjust the number so it's smaller.
If you're concerned about data loss, you can clone a new, separate clone of the server side and leave it untouched on your local system in case you need to roll. back.
I wasn't able to run the line above on Windows (I've installed ruby for this). It gave me error undefined local variable or method i' for main:Object (NameError)
. How do I fix it?
I think that these things should be in the documentation of migrate
command, because hitting a pack size limit is very possible, especially when using -export feature.
You'd definitely need to run that command in a Git Bash window on Windows and not on PowerShell or CMD. It definitely requires a POSIX shell to work.
As for placing this in the documentation of the migrate
command, I should point out that this isn't a Git LFS error. This is a Git error that's not specific to Git LFS, and it's specific to your particular server implementation. It can and does occur outside of using Git LFS.
Most helpful comment
Hey,
This is a message from your GitLab instance that the pack you've pushed is too large. Since you're rewriting history, many of the objects that the remote and local sides shared are no longer in common, and they must be sent again. GitLab provides an option to limit the size of the packs received, and you've hit that limit.
If your branch has a long history, you can try pushing a smaller number of commits at a time (say, 2000) with something like this:
That will walk through the history of
master
, pushing objects 2000 at a time. (You can, of course, substitute a different branch in both places if you like.) When that's done, you should be able to pushmaster
one final time, and things should be up to date. If 2000 is too many and you hit the problem again, you can adjust the number so it's smaller.If you're concerned about data loss, you can clone a new, separate clone of the server side and leave it untouched on your local system in case you need to roll. back.