Sub topic 10
Connecting a Git provider
This chapter assumes you know basic Git (commit, branch, push, pull), can navigate the Databricks workspace UI, and have an account with a supported Git provider such as GitHub, GitLab, Azure DevOps, or Bitbucket. You do not need to have cloned a repository yet. That comes in the next chapter.
Why credentials come first
A Git folder is a workspace folder linked to a remote repository. Databricks runs the Git operations (clone, fetch, commit, push, pull) on your behalf from the control plane. For the remote to accept those operations, it must know who you are. That requires two pieces of information stored in your Databricks user settings:
- Your Git provider, such as GitHub or GitLab.
- A credential that proves your identity to that provider.
The credential belongs to you as a user. Other people who open the same Git folder use their own credentials for their own Git operations. This is why the commit author on a push is the person who clicked the button, not a shared account.
Supported providers
Databricks supports the major hosted providers and also self-hosted or enterprise versions of several of them. The exact list changes over time, so check the Databricks documentation for your cloud and workspace. The common ones are:
| Provider | Typical credential |
|---|---|
| GitHub | Personal access token, or the GitHub app link |
| GitLab | Personal access token |
| Azure DevOps | Microsoft Entra ID sign-in on Azure, or a personal access token |
| Bitbucket Cloud | App password or access token with your username |
The options differ by provider and by cloud, so treat this table as a starting point and not as a complete list.
Adding a credential in the workspace
You add credentials in your user settings, not in a Git folder.
- Open your workspace and select your user name at the top right, then Settings.
- Open Linked accounts (the label may appear under the Git integration section, depending on workspace version).
- Choose your Git provider from the list.
- Enter your Git provider username or email, as the provider requires.
- Paste the personal access token (PAT) or other credential.
- Save.
A personal access token is a long random string that stands in for a password and can be limited to specific permissions. Providers prefer tokens over passwords because you can scope them, set an expiry, and revoke them without changing your account password.
Minimum token permissions
Give the token only what the workflow needs. As a rule:
- On GitHub, a classic token needs the
reposcope for private repositories. A fine-grained token needs read and write access to repository contents for the repositories you will use. - On GitLab, the
read_repositoryandwrite_repositoryscopes cover clone, pull, and push. - On Bitbucket, grant repository read and write.
A token with read-only access lets you clone and pull. A push then fails with a permission error, which is a common source of confusion (see the error table below).
Alternatives to personal access tokens
Depending on provider and cloud, you may be able to avoid long-lived tokens.
- GitHub app linking. Databricks can link to your GitHub account through an OAuth-style authorization flow. You approve access in the browser, and no token is pasted. Access can be limited to selected repositories and is easier to revoke centrally by your organization.
- Microsoft Entra ID for Azure DevOps. On Azure Databricks, the workspace can use your Entra ID identity to reach Azure DevOps in the same tenant, so you do not create a token.
- Service principals for automation. Automated pipelines and jobs should not run under a person's credential. Use a service principal (a non-human identity) with its own Git credential, so the job keeps working when an employee leaves.
Which method fits depends on your organization's security policy. Short-lived or app-based access is safer, and PATs are the simplest to set up.
Checking that the credential works
The quickest test is to try a Git operation:
- In Workspace, choose Create and then Git folder.
- Paste the HTTPS URL of a repository you can access, for example
https://github.com/your-org/your-repo. - Select the provider if it is not detected from the URL.
- Create the folder.
If the credential is valid, the repository contents appear. If not, an error message appears. You can also test the token outside Databricks. This command checks a GitHub token against a repository without cloning it:
git ls-remote https://github.com/your-org/your-repo.git HEADGit prompts for a username and password. Enter your username and use the token as the password. If this command succeeds, the token works and the problem is probably in how it was saved in Databricks. If it fails, fix the token first.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| "Authentication failed" or 401 when cloning | Token expired, revoked, or mistyped | Create a new token and replace it in Linked accounts |
| "Repository not found" or 404 on a private repo | Wrong URL, or the token cannot see the repository | Check the URL. Grant the token access to that repository |
| Clone and pull work, push fails with 403 | Token is read-only, or the branch is protected | Add write scope, or push to a feature branch and open a pull request |
| Works for a colleague but not for you | Credentials are per user | Check your own linked account, not theirs |
| Fails only for an organization repository on GitHub | The organization requires SSO authorization of tokens | Authorize the token for the organization at GitHub |
| Worked yesterday, fails today | Token reached its expiry date | Rotate the token and set a calendar reminder |
Edge cases to know about
- Only one credential per provider. Your settings hold one credential for each provider. If you work with two GitHub accounts, such as a personal and a work account, you can store only one at a time, so switch the saved credential or use the account that has access to both.
- HTTPS only. Databricks connects over HTTPS using the token. SSH keys that you use on your laptop do not apply here.
- Private networks. A self-hosted Git server that is not reachable from the Databricks control plane needs extra network setup, such as a proxy or an allowed route, before credentials matter. A timeout, as opposed to an authentication error, points to this.
- Token rotation. When you replace a token, existing Git folders pick up the new credential for your next operation. You do not have to re-clone.
- Admin controls. Workspace administrators can restrict which Git repository URLs are allowed, so a valid token can still be refused by a workspace policy. In that case the error mentions an allow list, and you must ask an admin.
Summary of the setup
Exercise
A teammate and you both use the same Git folder. You can pull and push, but your teammate can pull and gets a 403 on push. Where do you look first, and why?
Show answer
Look at your teammate's own linked Git credential, not yours. Credentials are stored per user, so the 403 means their token is probably read-only (missing write scope), lacks organization SSO authorization, or the branch is protected. Give the token write access, or have them push to a feature branch.
Exercise
Why should a scheduled production job not use your personal access token, and what should it use instead?
Show answer
A personal token is tied to one person. If that person leaves, changes role, or the token expires, the job fails. The job should run as a service principal with its own Git credential, so it does not depend on an individual.