Git versioning was always a sore point with notebooks. But nbdev takes care of that. From the documentation:
Jupyter Notebooks can cause challenges with git conflicts, but life becomes much easier when you use
nbdev
. As a first step, runnbdev_install_git_hooks
in the terminal from your project folder. This will set up git hooks which will remove metadata from your notebooks when you commit, greatly reducing the chance you have a conflict.But if you do get a conflict later, simply run
nbdev_fix_merge filename.ipynb
. This will replace any conflicts in cell outputs with your version, and if there are conflicts in input cells, then both cells will be included in the merged file, along with standard conflict markers (e.g.=====
). Then you can open the notebook in Jupyter and choose which version to keep.
You can find more in nbdev’s docs both on the tutorial
section as well as on the fix merge conflicts
section.