Monday 14 August 2023

Importing a Git Repo with LFS (Large Files) to Azure GIt Repos

 Importing a git repo to Azure DevOps Git is straight forward using the Azure DevOps portal. However, if the importing repo has large files with git lfs then the cloning of the repo after import fails due to the large files are not imported. Let's see how to get the large files fixed for the imported repo.

An example of large file import error is shown below.

Downloading somepath/AdobeDNGConverter.exe (64 MB)
Error downloading object: somepath/AdobeDNGConverter.exe (cd06721):
Smudge error: Error downloading somepath/AdobeDNGConverter.exe
(cd0672hash): [cd067hash] LFS object not found: [404] LFS object not found

Errors logged to 'C:\repos\myrepo\.git\lfs\logs\20230814T102105.1576211.log'.
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: somepath/AdobeDNGConverter.exe: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

When verified with the imported repo in the Azure DevOps portal the large files shown as nt imported but the file hash information is avalable.

To fix the issue we can execute the below steps.

Open Git bash and change directory to the locally unsuccessfull cloned repo. Then set the remote source as the original source repo where you have imported the repo from, using the command below.

 git remote add source <orginal source repo clone url>

Then execute a git lfs fetch from source which will download all the missing large files to your local repo.

 git lfs fetch source --all

Then make sure to add the remote target  as the newly imported Azure git repo clone url.
git remote add target <imported azure devops git repo clone url>

Executing command below will push all the missing files to the imported repo in Azure DevOps.

git lfs push target --all

Once completed in Azure git repo you can find the file is now available to download.

No comments:

Popular Posts