oererik
oererik

Reputation: 41

Importing repository in Azure DevOps with Git LFS

I am trying to migrate Bitbucket repositories to DevOps using the import repository function in DevOps. Some of those repositories have LFS enabled, and it looks like DevOps does not import the LFS files since when I clone the repo I got a lot of LFS errors. I tried to download a zip file of a commit, and while it should be around 12GB with all the files it was just over 600MB.

Does anyone know how to import repositories in DevOps with LFS enabled correctly?

Upvotes: 3

Views: 2880

Answers (2)

stuartdotnet
stuartdotnet

Reputation: 3034

What if my source repository contains Git LFS objects?

Git import will not import Git LFS objects.

LFS objects can be moved using the following steps:

  • Import the repository using import repository feature into Azure DevOps. This will copy over all the Git objects from source to Azure DevOps (this will also import the LFS pointers which are Git objects but not the LFS files)

To move over the LFS files (you will need both Git.exe and LFS client in the same box and access to both source repository and destination repository)

  • Clone the imported repository from Azure DevOps to local system, clone will work but it will fail while performing checkout of LFS files
  • Add the source repository as remote (say ‘source’)
  • Perform git lfs fetch source –all (this will bring over all LFS files from source to your local repository)
  • Assuming the destination VSTS repository is your ‘target’ remote
  • Perform git lfs push target –all

https://learn.microsoft.com/en-us/azure/devops/repos/git/import-git-repository?view=azure-devops#what-if-my-source-repository-contains-git-lfs-objects

Upvotes: 4

Linqen
Linqen

Reputation: 11

I run into the same issue, check the steps 2 and 4, basically the ones Microsoft's post didn't specified:

  1. Clone the imported repository from Azure DevOps to local system, clone will work but it will fail while performing checkout of LFS files

  2. Open git bash in your folder project or open cmd and go to that folder, then do:

    git remote add source https://github.com/git/git (replace that link with your repo's link)

  3. Perform git lfs fetch source --all (this will bring over all LFS files from source to your local repository)

  4. Perform git remote add target AzureRepoLink

  5. Perform git lfs push target --all (this step will push all LFS files to new repo)

  6. Clone your new repo again in a new folder and everything should be there

I'm sure step 4 can be done better, but it works this way.

I hope I helped!

Upvotes: 1

Related Questions