Sub topic 7
Revision history and collaboration
This chapter assumes you can create a notebook, attach it to compute, and run cells. It also assumes you know basic Git terms such as commit and branch. Here you will see how Databricks tracks changes to a notebook that is not yet in Git, and how several people can work in one notebook at once.
Revision history
Every notebook in your workspace keeps a revision history. Databricks saves versions automatically as you edit. You can also save a named version yourself.
To open it, choose Edit then Version history, or select the history icon in the notebook sidebar. The panel lists saved versions with a timestamp and the user who made them. From there you can:
- Preview an earlier version.
- Restore an earlier version, which replaces the current content.
- Save a version with a short comment, so it is easy to find later.
Restoring does not erase newer versions. The restore itself becomes part of the history.
Co-editing
Several users can open the same notebook at the same time. Each person's cursor and selection appear in the notebook, and edits show up for everyone within moments. This is useful for pairing, debugging, and reviews.
Co-editing has limits you should know about:
- Everyone shares the same attached compute and the same variable state. A cell that one person runs changes the state for all.
- Two people editing the same cell can overwrite each other's text.
- The user's permission on the notebook decides what they can do. Reading, running, editing, and managing are separate levels.
Comments
You can attach a comment to a cell. Select the cell, add the comment, and mention a colleague with @ so they are notified. Comments record questions and review notes next to the code they refer to. Replies stay in a thread, and you can resolve the thread when the issue is closed.
Permissions
A notebook has an access control list. The usual levels, from least to most access, are:
| Level | What the user can do |
|---|---|
| Can read | View cells and results |
| Can run | Attach to compute and run cells |
| Can edit | Change cells |
| Can manage | Change permissions and delete the notebook |
Give people the lowest level they need. A reviewer usually needs only Can read or Can run.
Why this is not enough for a team
Revision history is handy for undoing a mistake, but it has no branches, no pull requests, and no way to merge two lines of work. Co-editing also has no review step. These gaps are the reason to move shared code into a Git folder, which the next chapters cover.
Exercise
Two teammates edit the same notebook at once, and one of them wants to undo the other's change from an hour ago. Which feature do they use, and why is it not a substitute for a pull request?
Show answer
They use version history to preview and restore the earlier version. It is not a substitute for a pull request because it has no branches, no review step, and no way to merge separate lines of work.