I have started using IPython notebook quite a bit for writing up draft sections for my dissertation. However, given two versions of a draft (i.e., notebook), I would like to be able to generate some form of diff output to show what has changed. Does anyone know if this is currently possible, either through IPython notebook itself, or through some extension?
7 Answers
Notebook diff can be generated with nbdime. After installing nbdime you can run following to see notebook diff in browser:
> nbdiff-web notebook_1.ipynb notebook_2.ipynb
If you are using Github for version control you can use ReviewNB for Notebook diff. It lets you login via Github and browse commits/pull-request diff on your repo. You'll see visual diff like below:

- 436
- 4
- 7
-
Don't feel bad because I'm commenting on your post, it's simply the most recent mentioning nbdime. The web-based front-end failed to show the very first pair of notebooks I tried. The backend seems to spit out compare results but of course it is unable to handle image content and you get console spam. nbdime isn't ready for prime time yet. – StarShine Apr 10 '21 at 12:07
Try the following steps:
- Install
nbdime
by typingpip install nbdime
on a terminal. - Integrate with Git by typing
nbdime config-git --enable --global
on a terminal. - Type
nbdiff-web path/to/notebook.ipynb
on a terminal.
You can choose to ignore certain types of cells. For example, if you want to ignore output cells, type: nbdiff-web --ignore-outputs path/to/notebook.ipynb
.
More information on the different diff options here: https://nbdime.readthedocs.io/en/latest/cli.html#common-diff-options

- 61
- 1
- 1
-
Which versions are being compared? I tried the commands given and got null response, so perhaps the notebook is being compared with itself. – David Epstein Sep 24 '21 at 13:38
-
By "path" do you mean the path of the file, for example on a Unix system, or do you mean the web-address on, for example, Github? – David Epstein Sep 24 '21 at 15:22
Not yet. This is a often a requested feature, but there are different "level" of diff you might want. Do you want only diff of codecell, or also output, what about prompt number ? etc, etc.
Lots of people have chimed in but nobody really took the time to wrote anything, even if notebook are pretty "simple" json file where cell "just" need to be "aligned" then produce a diffed-json notebook.

- 27,170
- 6
- 80
- 74
Curvenote provides a chrome extension that allows you to put your notebook in version control and then you can diff individual cells nbdime
style, but also see previous outputs (plots, tables, streams,...) generated by the different versions of your code.

- 923
- 1
- 7
- 12