Skip to main content

Handle Merge Conflicts in Jupyter Notebooks

Handling merge conflicts can get tricky and often waste a lot of time. Merging in-file changes for a notebook can force the user to compare the metadata json. nbdev is the GQC preferred tool for maintaining repos where python notebooks needs to be present and maintained in different branches.

info

VSCode is unable to open the merge-editor for Jupyter Notebooks.

Here are the steps you should follow in-case, there is a merge conflict with a jupyter notebook,

  1. We mostly use notebooks with the nbdev, so make sure you have the hooks installed.
  2. Run the command, nbdev_install_hooks to install the hooks.
  3. VSCode would be unable to open the merge-editor.
  4. So stage the entire file directly, and then manually remove the code that you don't need.
  5. Add a commit message and then push the changes to the remote.

Merge-conflict

In case, you wish to understand this process in more detail, you can read about it over here.