Search code examples
gitbitbucketgit-lfs

git-lfs-migrate with Bitbucket gives "/objects/batch 501 (Not Implemented)"


I'm trying to migrate our Git repo to LFS like this:

java -jar git-lfs-migrate.jar -s our-repo.git -d our-repo-small.git -l https://user:[email protected]/bitbucket/scm/example/our-repo.git "*.jar"

LFS is enabled for the repository, but I'm getting:

[main] INFO git.lfs.migrate.Main - LFS server: Batch API request exception
ru.bozaro.gitlfs.client.exceptions.RequestException: https://user:[email protected]/bitbucket/scm/example/our-repo.git/objects/batch - 501 (Not Implemented)
        at ru.bozaro.gitlfs.client.Client.doRequest(Client.java:315)
        at ru.bozaro.gitlfs.client.Client.lambda$postBatch$7(Client.java:118)
        at ru.bozaro.gitlfs.client.Client.doWork(Client.java:252)
        at ru.bozaro.gitlfs.client.Client.postBatch(Client.java:118)
        at git.lfs.migrate.Main.checkLfsAuthenticate(Main.java:113)
        at git.lfs.migrate.Main.main(Main.java:66)
[main] ERROR git.lfs.migrate.Main - LFS server: Invalid base URL

We're on Bitbucket v4.6.2 but I couldn't find anythig related in the Bitbucket changelog since than.

Am I doing something wrong? Or does git-lfs-migrate use a feature that's not yet implemented by Bitbucket? If so, is there any workaround? I assume I'm not the first one doing this :-)


Solution

  • I managed to work around this thanks to a comment in the git-lfs-migrate issue tracker:

    git clone --mirror ./path/to/repo.git
    java -jar git-lfs-migrate.jar \ -s repo.git \ -d repo-converted.git \ "*.psd"
    cd repo-converted.git
    git fsck
    git remote add origin https://github.com/user/repo-converted.git
    git push origin master # (or git push --all origin)
    git lfs push --all origin
    

    Basically you just create all LFS files locally and then push them manually to the LFS server.