This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.
To use the script, follow the instructions given in the script's docstring.
For further details, read this blogpost.
The procedure outlined here is inspired by this answer on Stack Overflow.
looking for a way to solve this for Jupyter and there is a way to link this cleaning cycle to a pre-save hook via the jupyter_notebook_config.py:
https://jupyter-notebook.readthedocs.io/en/stable/extending/savehooks.html
(in case you can't find the Jupyter config)
https://stackoverflow.com/questions/32625939/ipython-notebook-where-is-jupyter-notebook-config-py-in-mac
I'm using this now and it works well. I haven't read all the details in this thread, but I guess you can solve a lot by diving more into these Jupyter hooks & config options.