Sub topic 10
Connecting a Git provider
Before a Git folder can clone, pull, or push, Databricks needs permission to act on your behalf at your Git provider. This chapter covers how to set up that link, which options exist, and the errors you are most likely to hit. It assumes you know basic Git and can navigate the workspace UI. You also need an account with GitHub, GitLab, Azure DevOps, or Bitbucket.
How credentials work
Git credentials belong to a user, not to the workspace. Each person links their own account, so commits and pushes show up under their own identity. A teammate cannot use your credential, and you cannot use theirs.
Databricks stores the credential and sends it to the provider whenever a Git folder operation needs it. Public repositories can be cloned without a credential, but push and pull on private repositories always need one.
Linking an account in the UI
- Open your user settings in the workspace and go to the linked accounts (Git integration) page.
- Choose your Git provider from the list.
- Select an authentication method. Options vary by provider:
- Linked account (OAuth). For GitHub, you authorize the Databricks app in your browser. No token is copied by hand, and the grant can be revoked from GitHub.
- Personal access token (PAT). You create a token at the provider and paste it into Databricks along with your username or email.
- Save. Databricks uses the credential from then on.
Personal access tokens
For a PAT, the token's permissions decide what Databricks can do.
| Provider | What to check |
|---|---|
| GitHub | A classic token needs the `repo` scope. A fine-grained token needs read and write access to repository contents. |
| GitLab | The token needs repository read and write scopes. |
| Azure DevOps | The token needs the Code (read and write) scope. |
| Bitbucket | Use an app password with repository read and write access, together with your Bitbucket username. |
If your organization enforces single sign-on on GitHub, authorize the token for that organization at GitHub. Otherwise the token is valid but the organization's repositories reject it.
Linking with the command line
Credentials can also be created from the Databricks CLI. This is useful when you set up many users or automate onboarding. Read the token from an environment variable so that it stays out of your shell history and your scripts.
export GITHUB_TOKEN="<paste token here>"
databricks git-credentials create gitHub \
--git-username "your-github-username" \
--personal-access-token "$GITHUB_TOKEN"Common errors
- Authentication fails right after setup. The username field is often the cause. Some providers need your username, and Azure DevOps expects your email.
- Clone works, push fails. The token has read-only scope. Create a new token with write access and replace the saved one.
- Everything worked yesterday. The token expired or was revoked. Create a new one and update the linked account.
- Organization repositories are not found. Single sign-on authorization is missing, or the token was not granted access to that repository.
Exercise
You can clone a private repository into a Git folder, but pushing a branch returns an authorization error. What is the most likely cause, and how do you fix it?
Show answer
The saved credential is probably a token with read-only permissions. Create a new token at the Git provider with write access to repository contents (for example, the repo scope on GitHub), then replace the credential in your Databricks linked accounts settings.