- Add a filter to git config by running the following command in bash inside the repo:
git config filter.strip-notebook-output.clean 'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to=notebook --stdin --stdout --log-level=ERROR'
-
Create a
.gitattributes
file inside the directory with the notebooks -
Add the following to that file:
*.ipynb filter=strip-notebook-output
After that, commit to git as usual. The notebook output will be stripped out in git commits, but it will remain unchanged locally.
This gist is based on @dirkjot's answer to this StackOverflow question.
It won't do anything because it waits for stdin input.
I don't have experience with conda, but if it works like venv, then that's where the problem is.
You'd need to install jupyter globally (easier) or modify filter to activate environment before running (harder). Try to run
pip install nbconvert
orpython3 -m pip install nbconvert
in git bash window. If it doesn't work: install python from python.org and remember to check "add python to PATH" or something similar. Maybe you can do it with conda, but I have zero experience with that.