Version control and CI/CD
Move a change from a Git branch into a deployment target. Define bundle resources and check, deploy, and run them with the CLI.
Git vocabulary you should know
Git is a distributed version control system: every clone holds the full history, so you can commit locally and exchange commits with a remote.
| Term | Meaning |
|---|---|
| Repository | The container for a codebase and its full history |
| Commit | A recorded set of changes (one or many files) with a message |
| Branch | An independent line of development for isolated changes. The default branch is usually main (formerly master) |
| Remote | A named reference to a copy of the repo hosted elsewhere (GitHub, GitLab, Azure DevOps) used to exchange commits |
| Clone | Create a full local copy of a remote repo, including history |
| Checkout | Switch to another branch or commit |
| Stage (add) | Select which changes go into the next commit. In a Databricks Git folder you tick the changed files in the Git dialog |
| Fetch | Download remote commits without changing your branch |
| Pull | Fetch and merge remote changes into your current branch |
| Push | Upload your local commits to the remote |
| Merge | Combine the histories of two branches |
| Reset | Discard or undo local changes |
Git folders (formerly Repos)
A Git folder is a workspace folder linked to a remote Git repository: GitHub, GitLab, Azure DevOps, Bitbucket, AWS CodeCommit and others. You authenticate with a personal access token or a Databricks GitHub App, set under User settings, Linked accounts.
Setting up a Git folder in practice

- Create one from Workspace, Create, Git folder (or New, Git folder). Git folders can live anywhere in the workspace; there is no longer a separate top-level Repos area to look in.
- Paste the repository's HTTPS URL. Private repositories need authentication: link GitHub through the Databricks GitHub App or a personal access token.
- Sparse checkout clones only selected subdirectories of a large repository.
- Error "GitHub account does not have access" for an organization repository: the Databricks GitHub App must be installed on that organization or repository by someone with admin rights on it.
- Git is attached at the folder level. To version an existing notebook, move it into the Git folder, then commit and push from the Git dialog.
- "Save now" in a notebook creates a revision in its version history, not a Git commit.
What you can do in the UI
- Clone a remote repo into a Git folder.
- Create a branch and switch branches from the Git dialog (branch name button at the top of a notebook or folder).
- See changed files, write a message, commit and push in one step.
- Pull remote changes. Resolve merge conflicts in the UI.
- Merge and rebase branches; reset to discard local changes.
- Create a pull request: the Git dialog links to the Git provider, where the PR is opened, reviewed and merged. Code review happens in the provider, not Databricks.
The development workflow: create a feature branch in a Git folder, edit notebooks, commit and push, open a PR in the Git provider, merge to main, then CI/CD deploys. Notebooks are stored in Git as source files (.py with # Databricks notebook source header, or .ipynb), so diffs are readable.
Typical layout: each developer has their own Git folder under their user folder for development. Production code is deployed by automation, not edited by hand in production.
Git folders vs notebook revision history
The video reports at least one exam question comparing Databricks Repos (now Git folders) with "native notebook versioning". In Databricks this means the revision history every notebook keeps automatically.
| Git folders | Notebook revision history | |
|---|---|---|
| Scope | Whole project (notebooks, .py files, configs) in a remote Git repo | One notebook at a time |
| Branching | Create, switch, merge, rebase branches | None, a single linear list of saved versions |
| Collaboration | Commit, push, pull; pull requests and review in the Git provider | Restore an earlier version, add comments to a version |
| CI/CD | Integrates with CI/CD tools (GitHub Actions, Azure DevOps) and bundles | No CI/CD integration |
| Storage | Remote Git provider, versioned outside the workspace | Inside the workspace only |
Choose Git folders whenever a question mentions branches, pull requests, code review, CI/CD or deploying the same code to several environments. Features such as fork, star, watch and issues belong to the Git provider (for example GitHub), not to Databricks. Authenticate with a scoped personal access token or the Databricks GitHub App, and revoke tokens you no longer need.
Declarative Automation Bundles New exam
Declarative Automation Bundles (formerly Databricks Asset Bundles, DABs) define your project as code: source files plus YAML describing resources such as jobs, pipelines, dashboards, schemas and volumes. The same bundle deploys to dev, test and prod with environment-specific settings. This is Databricks' recommended CI/CD approach.
Anatomy of databricks.yml
bundle:
name: sales_etl
include:
- resources/*.yml
variables:
catalog:
description: Target catalog
default: dev_catalog
db_password:
description: Database password, supplied at deploy time
resources:
jobs:
daily_sales:
name: daily_sales
tasks:
- task_key: ingest
notebook_task:
notebook_path: ./src/ingest.py
base_parameters:
catalog: ${var.catalog}
- task_key: transform
depends_on:
- task_key: ingest
pipeline_task:
pipeline_id: ${resources.pipelines.sales_pipeline.id}
targets:
dev:
mode: development
default: true
workspace:
host: https://dev-workspace.cloud.databricks.com
prod:
mode: production
workspace:
host: https://prod-workspace.cloud.databricks.com
variables:
catalog: prod_catalog
run_as:
service_principal_name: 6f1c...-sp
Key concepts
- Targets: named environments (dev, test, prod). Settings under a target override the top-level settings for that target only.
- Variables: declared in
variables, used as${var.name}. Values can come from (highest priority first): the--var="name=value"CLI option, an environment variableBUNDLE_VAR_name, a target'svariablesoverride, the variable'sdefault. Lookups such aslookup: cluster_policy: "Prod policy"resolve an object name to its ID. - Substitutions:
${bundle.target},${workspace.current_user.userName},${resources.jobs.x.id}. mode: development: prefixes resource names with[dev <user>], pauses schedules and triggers, deploys to the user's own folder so developers do not collide.mode: production: checks production settings, including development flags on pipelines and a target Git branch when configured. Databricks recommends a service principal as the production run identity.- Templates:
databricks bundle initstarts from a template (default Python, default SQL, pipelines, custom).
Do not hardcode a password in databricks.yml or the notebook. Keep runtime credentials in a secret scope and read them through dbutils.secrets.get. A CI environment can set deployment-time variables with BUNDLE_VAR_<variable_name>. Interpolating a password into an ordinary job parameter would still expose it in the deployed configuration.
The Databricks CLI
databricks auth login --host https://my-workspace.cloud.databricks.com # OAuth login, saves a profile
databricks bundle init # create a bundle from a template
databricks bundle validate -t dev # check YAML and resolve variables
databricks bundle deploy -t dev # upload files and create/update resources
databricks bundle run -t dev daily_sales # run a job or pipeline defined in the bundle
databricks bundle summary -t prod # show deployed resources and links
databricks bundle destroy -t dev # delete deployed resources and files
databricks bundle deployment bind ... # link an existing workspace resource to the bundle
databricks bundle generate job --existing-job-id 123 # create bundle YAML from an existing job
Other CLI groups manage workspace assets directly: databricks jobs, databricks clusters, databricks secrets create-scope / put-secret, databricks fs, databricks workspace, databricks repos. Profiles live in ~/.databrickscfg. In CI, authenticate as a service principal (OAuth machine-to-machine) using environment variables such as DATABRICKS_HOST, DATABRICKS_CLIENT_ID, DATABRICKS_CLIENT_SECRET.
Developing locally: VS Code extension and Databricks Connect
Databricks Connect is a client library for the Databricks Runtime. You write Spark code in your IDE (VS Code, PyCharm, IntelliJ, RStudio Desktop, notebook servers, custom apps) in Python, R or Scala, and it runs on Databricks compute (a cluster or serverless). It is built on open source Spark Connect: a decoupled client-server architecture where the client sends DataFrame operations as unresolved logical plans to a remote Spark cluster.
The Databricks extension for Visual Studio Code bundles Databricks Connect, authentication, bundle projects and remote runs.
What the video lab does
- Install the Databricks extension from the VS Code Extensions view.
- Create a configuration: host = your workspace URL (copy it from the browser, remove the trailing slash), then choose OAuth (user-to-machine) or Personal access token, and name the profile (for example
dev). Profiles are saved in~/.databrickscfg. - In the video, OAuth failed twice in VS Code even though the browser said "authenticated". The fix was to generate a personal access token (User settings, Developer, Access tokens) and use that. Never share tokens, and revoke them when finished.
- Create a project: the extension runs the bundle init flow. Template
default-python, project name with letters, numbers and underscores only, include the stub notebook and Python package, use serverless compute. If it nests a folder inside your folder, move it up one level. - Select the target (
dev) and the compute (serverless in the video). - Open
src/<project>/main.pyand click Run on Databricks. The run shows up under the job runs, and the output (5 rows of the NYC taxi sample read withspark.read.table) comes back to VS Code. It took about 1 min 23 s on serverless. - Notebooks in the project can also be run on Databricks as a workflow; each cell's output is visible in the run.
from databricks.connect import DatabricksSession
spark = DatabricksSession.builder.serverless().getOrCreate() # or .profile("dev")
spark.read.table("samples.nyctaxi.trips").show(5)
A CI/CD flow
- Developer works on a feature branch in a Git folder and deploys with
bundle deploy -t devto test. - They push and open a pull request.
- CI (for example GitHub Actions) runs
bundle validateand unit tests, and deploys to the test target for integration tests. - After merge to main, CD runs
bundle deploy -t prodas a service principal.
The same code is promoted unchanged; only target settings and variables differ.
Using notebook revision history as versioning, models in Unity Catalog to represent ETL jobs, or wheels in volumes alone are not the answer when a question asks for a modular way to deploy, version and orchestrate pipelines with CI/CD. The answer is bundles, versioned in Git.
Review a target change
A pull request points a production job at dev_catalog. Where should you fix the difference so the same transformation code can still run in development?
Check your reasoning
Use a bundle variable for the catalog and override it in the production target. Validate the target configuration before deployment.
Product reference
Declarative Automation Bundles in the Databricks documentation
Version control and CI/CD quiz
Answer 4 questions. Check each answer for an explanation.