The article describes how you can use common Git capabilities to sync Databricks Repos with a remote Git repository.
To update notebooks and other files in Databricks Repos, you can:
Pull changes from the remote Git repo.
Resolve merge conflicts.
Commit and push from Databricks to the remote repo.
You can also create a new branch in Databricks Repos.
To sync with Git, use the Git dialog. The Git dialog lets you pull changes from your remote Git repository and push and commit changes. You can also change the branch you are working on or create a new branch.
Git operations that pull in upstream changes clear the notebook state. For more information, see Incoming changes clear the notebook state.
You can access the Git dialog from a notebook or from the Databricks Repos browser.
From a notebook, click the button at the top left of the notebook that identifies the current Git branch.
From the Databricks Repos browser, click the button to the right of the repo name:
You can also click the down arrow next to the repo name, and select Git… from the menu.
To pull changes from the remote Git repository, click in the Git dialog. Notebooks and other files are updated automatically to the latest version in your remote repository.
To resolve a merge conflict, you must either discard conflicting changes or commit your changes to a new branch and then merge them into the original feature branch using a pull request.
If there is a merge conflict, the Repos UI shows a notice allowing you to cancel the pull or resolve the conflict. If you select Resolve conflict using PR, a dialog appears that lets you create a new branch and commit your changes to it.
When you click Commit to new branch, a notice appears with a link: Create a pull request to resolve merge conflicts. Click the link to open your Git provider.
In your Git provider, create the PR, resolve the conflicts, and merge the new branch into the original branch.
Return to the Repos UI. Use the Git dialog to pull changes from the Git repository to the original branch.
When you have added new notebooks or files, or made changes to existing notebooks or files, the Git dialog highlights the changes.
Add a required Summary of the changes, and click Commit & Push to push these changes to the remote Git repository.
If you don’t have permission to commit to the default branch, such as
main, create a new branch and use your Git provider interface to create a pull request (PR) to merge it into the default branch.
Results are not included with a notebook commit. All results are cleared before the commit is made.
For instructions on resolving merge conflicts, see Resolve merge conflicts.