Sub topic 7
Revision history and collaboration
This chapter covers how Databricks tracks changes to a notebook and how several people can work in one notebook at once. It also covers where that tracking stops and Git takes over. It assumes you can create and run a notebook, know basic Git terms (commit, branch, push, pull), and can find your way around the workspace UI. Git folders are covered in later chapters, so here they only appear as the place where team history ends up.
Two kinds of history
A notebook in the workspace has two separate records of change:
- Revision history is kept by the workspace. It saves snapshots of a notebook as you edit, and you can browse and restore them.
- Git history is kept by your Git provider. It holds the commits you deliberately create, with messages, authors, and branches.
They answer different questions. Revision history asks, "What did this notebook look like an hour ago, before I broke it?" Git history asks, "Who changed the cleaning logic last month, and why?"
| Aspect | Revision history | Git history |
|---|---|---|
| Created by | The workspace, automatically | You, with an explicit commit |
| Granularity | Snapshots of the whole notebook | Commits with messages |
| Lives in | The workspace | The Git repository |
| Branches and review | No | Yes |
| Best for | Quick undo while working | Team record and code review |
Revision history in a notebook
Databricks saves notebook edits automatically, so you never press a save button. As you work, the notebook records versions that you can inspect later.
To open the history, use the version history icon in the notebook's right sidebar. The exact icon and menu label can differ between workspace releases. The panel lists versions with a timestamp and the user who made the change. From there you can:
- Select a version to view the notebook as it was.
- Restore that version, which replaces the current content with the older one.
- Delete a single version or clear the whole history.
Restoring is not destructive in the way you might fear. The restore itself becomes a change that is also recorded, so you can usually return to what you had before restoring. Clearing the history is different. It removes the saved versions and cannot be undone.
You can also save a named version explicitly, with a short comment. Do this before a risky refactor, for example "before switching to the new schema." A comment makes the version easy to find in a long list of automatic ones.
Collaborating in one notebook
Several people can open the same notebook at the same time. This is called coauthoring. You see other users' avatars at the top of the notebook, and you see their edits as they type, without refreshing. Typical uses are pair debugging, a walkthrough with a colleague, and a shared analysis session.
What is shared and what is not
- The notebook's code and cell layout are shared. Everyone sees the same cells.
- Cell results shown in the notebook are shared when someone runs a cell.
- Compute is attached to the notebook as a whole. If one person runs a cell on the attached cluster, that run uses the cluster everyone is using.
- Widget values and variables belong to the running session on the compute, so they are tied to whoever last set them. Two people changing the same widget can confuse each other.
Because compute and state are shared, coauthoring works best when people agree who is running what. Two people editing different cells at once is fine. Two people running cells that rewrite the same table is not.
Permissions decide who can do what
Access to a notebook is controlled by permission levels. From least to most capable, they are:
| Level | What it allows |
|---|---|
| No Permissions | The notebook is not accessible |
| Can Read | View the notebook, its results, and comments |
| Can Run | Run the notebook on compute you can use, and comment |
| Can Edit | Change the notebook's cells |
| Can Manage | Change the notebook's permissions, and everything above |
A common setup is Can Manage for the owner, Can Edit for the team, and Can Read for stakeholders who only need to see results. Check your workspace's documentation for how permissions interact with folder-level settings, since a notebook usually inherits access from its folder.
Comments
You can attach a comment to a cell. Select the code you want to discuss, add a comment, and mention a colleague with @ followed by their name. The person you mention can be notified, and the thread stays next to the code. Comments are useful for asking "why this filter?" without editing the code. Treat them as workspace conversation. They are not part of the notebook's source file, so they do not travel with the code into Git.
What happens with Git folders
When a notebook lives in a Git folder, the workflow changes. Real-time coauthoring is still possible in the workspace, but the durable team process is Git:
- Each person usually works on their own branch.
- Changes become commits, which are pushed and reviewed through a pull request.
- The commit history on the provider is the record of who changed what.
Revision history remains useful inside this flow as a short-term undo between commits. It does not replace committing.
Shared editing versus separate branches
Two people can work in the same notebook in the same Git folder at once. They will see each other's edits live, but the Git folder only has one working copy, so a commit captures everything that is in it. If two people edit simultaneously and one commits, the commit includes both people's changes. This often surprises teams.
For that reason, many teams give each developer a personal Git folder and a feature branch. Live coauthoring is saved for short, deliberate sessions. This keeps commits attributable and avoids committing a colleague's half-finished work.
Reading history from the repository
Once the notebook has been committed as a source file, ordinary Git commands show its history. The notebook is a text file, so git log and git blame work on it. The path below is an example. Use your own.
git log --oneline -- notebooks/daily_load.py
git blame notebooks/daily_load.pyThe first command lists commits that touched the notebook. The second shows which commit last changed each line.
Common mistakes
- Relying on revision history as the only record. It can be cleared and is not reviewable. Commit work that matters.
- Committing someone else's edits. In a shared Git folder, a commit includes every change in the working copy. Review the changed files in the commit dialog before you push.
- Running cells at the same time on shared state. Two people running overlapping cells can overwrite variables or tables. Agree on who runs.
- Expecting comments to appear in Git. They stay in the workspace.
- Restoring an old version while others are editing. Everyone viewing the notebook sees the replaced content. Tell the people working in it first.
Exercise
Two teammates edit the same notebook at the same time in one shared Git folder. One of them commits and pushes. Whose changes are in the commit, and what would you recommend the team do to avoid this?
Show answer
The commit includes all changes in the Git folder's working copy, so it contains both teammates' edits, including any unfinished ones. To avoid this, give each person a personal Git folder on a feature branch and use live coauthoring only for short sessions. When coauthoring in a shared folder, review the changed files before committing.
Exercise
You restored an older notebook version and later realized you needed the content you had before restoring. Where would you look first, and what is the longer-term fix?
Show answer
Look in the notebook's revision history, because the restore is recorded as a change and the earlier content is usually still available as a version. The longer-term fix is to commit meaningful states to Git, so recovery does not depend on workspace history that someone can clear.