Search code examples
bitbucketbitbucket-api

Enable Git-LFS on BitBucket Server using REST API


I need to interact programmatically with a BitBucket Server to create and manage repositories.

To create a repository, a corresponding REST API method is available.

The created repositories should have LFS enabled. In the Web-UI, there is a simple checkbox to do this. But I was not able to find anything in the REST API to enable LFS programmatically.

Does anybody know of any API to enable LFS in a BitBucket repository?

I tried some variants in the API urls to see if there are undocumented methods (e.g. ...{repo-slug}/settings, but wasn't successful (receiving http status code 405).


Solution

  • A colleague has found a non-official solution to the problem in an Atlassian JIRA thread

    There it is reported that:

    There's actually an undocumented endpoint for interacting with LFS. It's rough and clearly not polished, but it works.

    rest/git-lfs/admin/projects/<key>/repos/<slug>/enabled

    GET will return a 200 if it's enabled, 404 if it's disabled.
    PUT to enable
    DELETE to disable

    So let's hope this undocumented feature remains available for those that need this functionality... use it at your own risk.