nbdev2 Solves Jupyter's Git Collaboration Nightmare with Automated Merge Drivers
November 13, 2025 · 3 min read
For years, data scientists and machine learning engineers have faced a fundamental collaboration problem: Jupyter notebooks and Git version control simply don't play well together. The JSON-based format of Jupyter notebooks creates unreadable merge conflicts, broken files, and collaboration headaches that have forced teams to abandon notebooks for traditional Python scripts when working collaboratively.
Fast.ai's nbdev2 platform has now comprehensively solved this long-standing issue. The open-source development environment introduces automated Git merge drivers that handle notebook conflicts at the cell level rather than line level, preserving the interactive notebook experience while enabling seamless version control. The solution represents years of iterative development by the fast.ai team, including contributions from Jeremy Howard, Sylvain Gugger, Wasim Lorgat, and Stas Bekman.
The core innovation lies in replacing Git's default line-based merging with a cell-aware approach. Using Python's built-in difflib module and SequenceMatcher class, nbdev2's 58-line merge driver identifies conflicts based on cell source code while ignoring execution counts and metadata differences that typically trigger false conflicts. When conflicts do occur, they're presented as separate cells within Jupyter, allowing developers to simply delete unwanted versions or combine changes directly in the notebook interface.
Beyond local merging, nbdev2 addresses remote collaboration challenges through Jupyter's pre-save hooks. These automatically strip unnecessary metadata before commits, eliminating the execution count conflicts that frequently block pull requests on platforms like GitHub. The combination of intelligent merging and proactive cleaning has transformed workflows at fast.ai, where all library development—including tests, documentation, and source code—occurs entirely within notebooks.
The platform's effectiveness stems from its minimal configuration requirements. Running 'nbdev_install_hooks' once sets up the necessary Git configurations, after which teams can collaborate on notebooks as effortlessly as they would with traditional code files. For organizations already using ReviewNB for notebook-specific code reviews, nbdev2 provides complementary functionality that handles the version control aspects ReviewNB doesn't address.
While alternatives like Jupytext exist by converting notebooks to line-based formats, they struggle with output preservation and create their own management complexities. Nbdime offers similar conflict resolution but isn't compatible with nbdev2's approach. Fast.ai's solution stands out by working within Jupyter's native environment rather than requiring format conversions or additional tooling.
The impact extends beyond fast.ai's own repositories, which handle contributions from hundreds of developers. For the broader data science community, nbdev2 represents a maturation of notebook-based development, finally delivering on the promise of interactive exploration without sacrificing collaboration capabilities. As organizations increasingly adopt notebooks for production machine learning workflows, tools that bridge the gap between experimentation and engineering become increasingly critical.