Search code examples
gitgitlabatlassian-sourcetreegit-lfs

Git-LFS add filetypes (without doubling repo size)


I have a big repo on GitLab.com (8GB) with some assets (textures, etc). I decided to use git lfs for the sometimes above 50MB files.

I started with git lfs migrate import --include="*.png" and did git reflog expire --expire-unreachable=now --all git gc --prune=now and tracked the filetype (track, commit .gitattributes, push)

The problem is that my repository size nearly doubled and I can't push new content, not even the .gitattributes because of the 10GB sizelimit

How can I tell git that git lfs has already tracked the .png files and that the original versions in the repo can be deleted? (I thought that migrate would exactly do that, but it doesn’t)

Update: I did a test-repo with just 1 bigger file. And the outcome is the same. I have doubled the repo size, because the file seems to be in the normal repo and lfs at the same time. In gitlab.com it is shown with a lfs tag tough.


Solution

  • By default, Git LFS will migrate only the current reference (usually the current branch). If you want to migrate your entire repository, which is almost always what you want to do, you need to use the --everything option to git lfs migrate import so that it will traverse all branches and tags.

    Note that if your repository has a tag pointing to another tag, which is uncommon but sometimes occurs, that tag will not be migrated in the current version.