Copy nbflatten.py to somewhere on $PATH. Then, in the root of a git repository, run these commands:
echo "*.ipynb diff=ipynb" >> .gitattributes
git config diff.ipynb.textconv nbflatten.py
When you change a notebook and run git diff
, you'll see the diff of flattened, simplified notebooks, rather than the full JSON. This does lose some information (metadata, non-text output), but it makes it easier to see simple changes in the notebook.
This doesn't help with merging conflicting changes in notebooks. For that, see nbdiff.org.
Modification to @jfeist's snippet for
.gitconfig
. More details here ( jqlang/jq#921 ). Also, double quotes must be escaped in single quotes with.gitconfig
. ( http://stackoverflow.com/a/25535431 )