Ban your nnotebooks commits if their output cells are not empty.
Copy pre-commit
to your repo hooks:
cat pre-commit >> .git/hooks/pre-commit
It doesn't change your notebook. It doesn't even It unstages files, rejects the commit and remindes you of your notebook cell outputs state for committing if you have forgotten to clean them.git reset
for you.
You need underscore-cli for using this hook.
npm install -g underscore-cli
underscore help
For having more control over the process or manipulating the notebooks you can use nbstripout and nb-clean.