At Databricks, we are committed to simplifying the developer experience and are thrilled to unveil additional Git capabilities in Databricks Repos. Users can now run Git merge and Git rebase and resolve merge conflicts directly from the Repos UI.
New Operations: Merge & Rebase
Each operation is a way to combine the commit history from one branch into another branch; the only difference is the strategy it uses to achieve this. For beginners, we recommend using merge at first, because it does not require force pushing to a branch and therefore does not rewrite commit history. Rebase provides a cleaner project history, but rewrite that history, which can lead to issues. Databricks enables teams to choose what works best for them. To learn more about the differences between the strategies, please see Atlassian's documentation on the subject.
What Causes Merge Conflicts?
Merge & Rebase Operations
During a merge or rebase, a merge conflict is encountered when Git cannot automatically combine code from one branch into another. Sometimes two people have modified the same line of code and therefore it is impossible to automatically decide which one should be kept. Merge conflicts require manual resolution before a merge or rebase can be completed.
Pull Operation
A pull operation pulls commits from a remote branch to a local one. A pull operation can be run even while a user might have uncommitted, outstanding changes. This means that if the uncommitted changes conflict with the commits being pulled from remote, the result will be a merge conflict that needs resolving.
How to Resolve Merge Conflicts
If you have a merge conflict, the Repos UI provides tools to resolve them:
- Manually Resolve Conflicts: Use the code editor to remove conflict markers and edit the file as needed, then click the "Mark as Resolved" button.
- Keep All Current or Take Incoming Changes: Another way of resolving merge conflicts is to let Git edit the file for you. If all of the changes from one branch or the other is desired, the dropdown options can be used to Keep all current changes or Take all incoming changes.
- Tip: Confused about which option to pick? The color of each option matches the respective code changes that it will keep.
At any time, if the changes were not desired, the "Abort" button can be used to abort the process and undo everything. Once all conflicts are resolved, click the "Continue Merge" or "Continue Rebase" option to resolve the conflict and complete the operation.
For more information, see Git operations in Databricks.
Conclusion
Databricks continues to innovate to provide powerful and user-friendly tools for data scientists and engineers. The new Git merge, Git rebase and conflict resolution features in Repos make collaboration more effective and seamless, further enhancing the developer experience. Ready to get started? Try running a merge or rebase operation within Databricks or dive deeper into the Databricks Repos documentation to learn more.