Skip to content

Instantly share code, notes, and snippets.

@betatim
Forked from matsen/md-nb-diffs.md
Last active October 8, 2017 14:08
Show Gist options
  • Save betatim/cbaea383a69e68b3dd1d87f90fd34eaf to your computer and use it in GitHub Desktop.
Save betatim/cbaea383a69e68b3dd1d87f90fd34eaf to your computer and use it in GitHub Desktop.
Markdown diffs for jupyter notebooks. Makes `diff`ing notebooks less tedious.

For sane jupyter notebook diffs

Install the nbconvert package, though you probably already have it if you are using jupyter. Put the nb2md script from below in your path and make it executable (chmod u+x).

nb2md for all your projects

  1. Add the following to your ~/.gitattributes file *.ipynb diff=nb2md
  2. Run git config --global diff.nb2md.textconv nb2md
  3. There is no third step. Go get some 🍦 instead.

nb2md for some projects

  1. Edit .gitattributes in the top-level directory of your project and add *.ipynb diff=nb2md
  2. add the following to your project's .git/config
 [diff "nb2md"]
        textconv = nb2md
  1. There is no third step. Go get some 🍦 instead.
#!/bin/sh
jupyter nbconvert --to markdown $1 --stdout --log-level=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment