Sub topic 2
Revision History and Collaboration in Databricks
Assume you know basic Python or SQL, Git concepts such as branches and commits, and the Databricks workspace UI. This chapter connects notebook collaboration to Git-based development.
Revision history and collaboration
A notebook's revision history records saved versions, who saved them, and when. Use it to inspect changes, restore an earlier version, or compare revisions before asking a teammate to review work. Workspace permissions still control who can edit or run the notebook. Revision history is useful for recovery, but it is not a replacement for a shared Git workflow.
How a notebook is stored as a source file
Databricks can represent a notebook as a source file. Each cell is separated by a marker, and language magic commands are stored as comments so the file remains valid source code. This makes notebook changes visible to Git and code review tools.
# Databricks notebook source
# MAGIC %md
# MAGIC # Daily load
# COMMAND ----------
df = spark.range(5)
display(df)
# COMMAND ----------
# MAGIC %sql
# MAGIC SELECT 1 AS one| Notebook feature | Source-file representation |
|---|---|
| Cell boundary | `# COMMAND ----------` |
| Markdown or SQL cell | `# MAGIC` comments |
Git folders: what they are and why use them
A Git folder is a workspace folder linked to a remote Git repository. It lets you edit notebooks and ordinary files in the workspace while keeping branches, commits, and pull requests in Git. Use workspace revision history for quick recovery. Use Git folders when the team needs review, shared history, reusable modules, and repeatable deployment.
Connecting a Git provider
In Databricks user settings, add credentials for a supported provider such as GitHub, GitLab, Azure DevOps, or Bitbucket. Use the provider's recommended token or authentication method, and grant only the repository access you need. An administrator may restrict allowed providers or credential types.
Cloning a repository and working on a branch
Create a Git folder by supplying the repository URL and a workspace location. After it loads, switch to a feature branch before editing. Save notebooks, review the diff, then commit and push the branch. Pull remote changes before continuing. If both versions changed the same lines, resolve the conflict locally, test the notebook, and commit the resolution.
git checkout -b feature/clean-orders
git add -A
git commit -m "Clean orders notebook"
git push -u origin feature/clean-ordersExercise
When should you use a Git folder instead of only notebook revision history?
Show answer
Use a Git folder when changes need shared branches, code review, reusable files, or automated deployment.