I recently decided to try migrating a private repository from github.com to gitlab.com since GitLab seems to have shipped a lot of great features recently. GitLab has a feature that allows you to import repositories, including Issues from Github, so I decided to give it a try.

After GitLab was done importing, however, I was disappointed to find that it had not actually copied over several assets I had checked in with LFS. All the references to those assets were still pointing to Github.

After getting over my initial disappointment, and filing an issue, I figured hey, this is still git. I can do the LFS migration myself.

I set about googling for answers on how to migrate git repositories with LFS, but to my dismay, I did not find any information about this. There are loads of blog posts that refer to migrating assets from a vanilla git repository to LFS, but nothing about what I was trying to do.

So I started digging around in man pages, and eventually found git lfs fetch and git lfs push.

Turns out, you can use these commands to migrate lfs assets as well.

I’m assuming you have your original LFS enabled repository on github cloned (this remote is assumed to be origin). You’ve also imported it into GitLab with their importer, and added it as a remote (called gitlab).

Now, run:

git lfs fetch --all 
git lfs push gitlab --all 

This can take a while (it will show progress), but once it’s done, you’re good to go!

Hopefully, if you use git LFS, this gives you some peace of mind that if the need arises, you will be able to migrate to another git host if you so choose without too much hassle 😀.

Gopal Sharma

gps gopalkri


Published