Jupyter Notebook Diffs

Hey all!

So, I’m not sure how often the rest of you update the git repo, or how often you modify the existing notebooks (or always just make copies), but I run into a lot of merge conflicts.

I git stash, then git pull then try to git stash pop and it’s merge conflict city.

It sucks to deal with the merge conflicts- as great as Jupyter Notebooks are, and as parsable as JSON is, manually resolving the merge conflicts is painful.

The important bit:

So, I googled around a bit and found nbdime.

(install with pip install nbdime)

Check it out. It’s phenomenal.

There’s a web view tool, and a native git integration.

23 Likes

Oh wow that’s rather terrific.

Awesome find! That’s something I struggle with both with the Fast.ai library and at work.

Sweet … thanks for sharing !!

I just make copies of notebook and name the new notebooks starting with “tmp_” .
This makes git ignore the file. I think Jeremy mentioned this in one of his videos.

True - but just to clarify, it’s only because I put tmp* in the fastai .gitignore - it’s not a general git thing.

1 Like

Oh. Didn’t know that it is managed by git ignore. Good to know. Thanks.

nbdime is great for local diff/merge. If you need to diff Notebooks stored on GitHub, checkout ReviewNb. I wrote more about it here.

Disclaimer: I built ReviewNb.