Reputation: 30087
I have a git repo where many files should be lfs because they are larger than 100M.
Looking around I was unable to find a step by step guide that explain how to migrate a real existing repo with many branches and where lfs files are within subdirectories.
In my case large files are spread around the repo like this:
code/track1/file000.pkl
code/track3/dat000.bin
code/track4/pip000.pkl
code/subcode/track5/pip000.pkl
code/subcode/track5/pop000.model
I suppose to convert the git project into git lfs just using git lfs migrate
:
git lfs install
git lfs migrate import --include="*.pkl"
git lfs migrate import --include="*.bin"
git lfs migrate import --include="*.model"
git commit -m "migrating models"
but this does not do anything.
nothing to commit, working tree clean
I want convert all the repo, I mean all the files, the history and also all existing branches.
In other words, git lfs migrate
seems to be stable now but not so user frendly.
Running git lfs track "*.pkl"
seems to have an effect:
modified: code/track1/file000.pkl
modified: code/track4/pip000.pkl
modified: code/subcode/track5/pip000.pkl
but what to do next. I see that git lfs track
will begin tracking a new file or an existing file that is already checked in to your repository.
But what about the history? I'm struggling because I don't want end up with a messed repository that I have to reimport from scratch or where have to deal with filter-branch..
Upvotes: 7
Views: 15578
Reputation: 7268
Git LFS provide a tutorial on how to use git lfs migrate
A few things to mention:
git lfs migrate import --include="*.pkl"
, it adds that to the .gitattributes to be tracked under LFS, and migrates .pkl files to LFS throughout your history. As such, you don't need to call git commit
afterwards. Note, this would be different if you call git lfs import migrate --no-rewrite, which as the docs indicate leads to a separate commit in which the files are migrated to LFS. (But, given what you've indicated in your question, I don't think that's what you want.)--everything
, which the docs indicate includes all local and remote branches in the migration.git lfs ls-files
to see which files are currently tracked and stored under LFS. Also, you might want to run the LFS migration with --verbose
, which will print out the specific files that have been moved to LFS storage as it progressed through the migration.Upvotes: 8