I'm trying to add a git clean-filter in order to ignore outputs and execution_count from my IPython notebook files.
I've basically followed this article (based on this SO answer) and modified it slightly for my needs. Also, I'm on Windows so the part about making the python script executable isn't needed as far as I know (see Python FAQ).
I want to bundle that to my repository so that other contributors get it too.
I've saved the ipynb_drop_output.py
at the root of my repository and saved the gitconfig and gitattributes files at the same place so at the root I have:
.gitignore
.gitconfig
.gitattributes
ipynb_drop_output.py
MyNotebook.ipynb
In .gitattributes
:
*.ipynb filter=clean_ipynb
In .gitconfig
:
[filter "clean_ipynb"]
clean = ipynb_drop_output.py
smudge = cat
I've tested the code of my ipynb_drop_output manually and it works like a charm. Yet git diff
still shows me execution_count and outputs that changed. It appears the script isn't running at all.
I'm thinking it might be because of the clean = ipynb_drop_output.py
section, but I've tried every variation: not include the .py, include the full path "C...\ipynb_drop_output.py", with forward slashes too etc.
My second theory is that git is just not looking at the .gitconfig file but I'm unclear how to tell it to and/or how to check that it is actually looking at it. And I thought the point of git config --file .gitconfig filter.clean_ipynb.clean ipynb_drop_output
was to do just this...
How can I make it work on Windows please?