Reputation: 888
Recently, I enabled git lfs for my gitlab project while checking in a 200 MB file. And this I could successfully and verify that in remote this new 200 MB file shows LFS
.
In the past I had checked-in few 10 MB files without lfs. Those exist in remote too. What is the best way to migrate those to lfs?
I tried following:
git lfs migrate import --everything --include="*.pkl" --verbose
And then when I try git push
, I get an error -
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'yourgit.internal.yourdomain.com:<user>/project.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git pull
does not work either. What is the way to migrate existing files to lfs? Will adding --include-ref=refs/heads/master
to the migrate command help?
And do I need to do anything extra for the other branches?
Upvotes: 0
Views: 1733
Reputation: 30878
git lfs migrate import
rewrites the branches. So, the branches in the local repository are diverged with the branches in the remote repository. That's why the push fails due to non-fast-forward. In this case, git pull
is not suitable. It would merge the original branch and the rewritten one, making the effort of git lfs migrate import
in vain. Instead, you need to force-push the local branches to the remote repository.
The repository size on Gitlab is not going to reduce significantly as the remote repository has some internal refs that reference to the old objects. But a new clone is expected to be much smaller than before.
Upvotes: 1