Repos CLI

Note

The Repos CLI requires Databricks CLI 0.15.0 or above.

You run Databricks repos CLI subcommands by appending them to databricks repos.

For more information about repos, see Git integration with Databricks Repos.

databricks repos --help
Usage: databricks repos [OPTIONS] COMMAND [ARGS]...

  Utility to interact with the repos API.

Options:
  -v, --version   [VERSION]
  --debug         Debug mode. Shows full stack trace on error.
  --profile TEXT  CLI connection profile to use. The default profile is
                  "DEFAULT".

  -h, --help      Show this message and exit.

Commands:
  create      Creates a repo.
  delete      Deletes a repo.
  get         Lists information about a repo.
  list        Lists all available repos in the workspace.
  update      Updates information about a repo.

Create a repo

To display usage documentation, run databricks repos create --help.

Usage

databricks repos create --url <url> --provider <provider> --path <path>

Replace:

  • <url> with the required Git provider’s URL to the repo.

  • <provider> with the required Git provider’s name, for example gitHub. Available providers include:

    • azureDevOpsServices

    • bitbucketCloud

    • bitbucketServer

    • gitHub

    • gitHubEnterprise

    • gitLab

    • gitLabEnterpriseEdition

    The provider’s name can be specified as case-insensitive (for example, gitHub and github are both valid).

  • <path> with an optional path to the repo in the Databricks workspace, for example /Repos/someone@example.com/my-repo.

Example output

{
  "id": 1234567890123456,
  "path": "/Repos/someone@example.com/my-repo",
  "url": "https://github.com/my/my-repo",
  "provider": "gitHub",
  "branch": "master",
  "head_commit_id": "9837ac1f924a5ca56117597c5c79bb02300ff1f4"
}

List all available repos in the workspace

To display usage documentation, run databricks repos list --help.

Usage

databricks repos list --path-prefix <path-prefix> --next-page-token <next-page-token>

Replace:

  • <path-prefix> with an optional path prefix to the repos in the Databricks workspace, for example /Repos/someone@example.com/my-repo.

  • <next-page-token> with an optional next page token provided by running the command previously, to get the next page of results.

Example output

{
  "repos": [
    {
      "id": 1234567890123456,
      "path": "/Repos/someone@example.com/my-repo",
      "url": "https://github.com/my/my-repo",
      "provider": "gitHub",
      "branch": "master",
      "head_commit_id": "9837ac1f924a5ca56117597c5c79bb02300ff1f4"
    },
    {
      "id": 2345678901234567,
      "path": "/Repos/someone@example.com/my-repo-2",
      "url": "https://github.com/my/my-repo-2",
      "provider": "gitHub",
      "branch": "master",
      "head_commit_id": "837ac1f924a5ca56117597c5c79bb02300ff1f4a"
    }
  ]
}

List information about a repo

To display usage documentation, run databricks repos get --help.

Usage

databricks repos get --repo-id <repo-id> --path <path>

Replace:

  • <repo-id> with the ID of the repo, for example 1234567890123456. To get the ID, run the list command. --repo-id or --path is required.

  • <path> with the path to the repo in the Databricks workspace, for example /Repos/someone@example.com/my-repo. To get the path, run the get or list command. --repo-id or --path is required.

Example output

{
  "id": 1234567890123456,
  "path": "/Repos/someone@example.com/my-repo",
  "url": "https://github.com/my/my-repo",
  "provider": "gitHub",
  "branch": "master",
  "head_commit_id": "9837ac1f924a5ca56117597c5c79bb02300ff1f4"
}

Update a repo to the most recent commit of a remote branch or to a tag

To display usage documentation, run databricks repos update --help.

Usage

databricks repos update --repo-id <repo-id> --branch <branch>

Or:

databricks repos update --repo-id <repo-id> --tag <tag>

Or:

databricks repos update --path <path> --branch <branch>

Or:

databricks repos update --path <path> --tag <tag>

Exactly one of --repo-id or --path is required, and exactly one of --branch or --tag is required.

--repo-id or --path identifies the Databricks Repo that should be updated. --branch or --tag identifies the commit to update to or the new branch to check out. If --branch or --tag refers to the branch that is currently checked out, Databricks Repos performs a pull operation to update to the latest commit for that branch. If --branch or --tag refers to a branch not currently checked out, Databricks Repos checks out the specified branch.

Replace:

  • <repo-id> with the ID of the repo, for example 1234567890123456. To get the ID, run the list command.

  • <path> with the path to the repo in the Databricks workspace, for example /Repos/someone@example.com/my-repo. To get the path, run the get or list command.

  • <branch> with the name of the branch in the repo to use, for example my-branch.

  • <tag> with the name of the branch in the repo to use, for example my-tag.

Example output

{
  "id": 1234567890123456,
  "path": "/Repos/someone@example.com/my-repo",
  "url": "https://github.com/my/my-repo",
  "provider": "gitHub",
  "branch": "my-branch",
  "head_commit_id": "9837ac1f924a5ca56117597c5c79bb02300ff1f4"
}

Delete a repo

To display usage documentation, run databricks repos delete --help.

Usage

databricks repos delete --repo-id <repo-id>

Or:

databricks repos delete --path <path>

Replace:

  • <repo-id> with the ID of the repo, for example 1234567890123456. To get the ID, run the list command. --repo-id or --path is required.

  • <path> with the path to the repo in the Databricks workspace, for example /Repos/someone@example.com/my-repo. To get the path, run the get or list command. --repo-id or --path is required.

If successful, no output is displayed.