gitazure-devopsgit-lfsgit-lfs-migrate

How to transfer a git repository with LFS file to another repository?


We have a local git server, with LFS files. We are planning to move everything on MS Azure DevOps. After some research, I read that it was advise to do a "mirror" clone, to have everything(tags at least):

git clone --mirror

Then, since I've some LFS files, I wanted to get them too:

git lfs fetch --all

But I get this error:

Error: Failed to call git rev-parse --git-dir --show-toplevel: "fatal: this operation must be run in a work tree\n"
Not in a git repository.

For what I'm reading, git lfs fetch doesn't work on a bare repository(not that I know what this is, but I think it's related to the --mirror option.

So my question is: What should I do to transfer everything to this new repository? (the local server will be shutdown after this).

Thank you


Solution

  • What should I do to transfer everything to this new repository? (the local server will be shutdown after this).

    That because the incompatibility between git-lfs and the default directory name that git uses for bare repos.

    To resolve this issue, you could try to use following git commands:

    git clone --bare https://xxx/xxx/old-repository.git
    cd old-repository.git
    git lfs fetch --all
    git push --mirror https://xxx/xxx/new-repository.git
    git lfs push --all https://xxx/xxx/new-repository.git
    

    You could check this document Mirroring a repository that contains Git Large File Storage objects for some details.