How to add filter driver command from gitattributes automatically on git clone?

46 views Asked by At

I'm using a strategy to filter ipynb notebooks described in the top answer here, with this in my .gitattributes

*.ipynb filter=strip-notebook-output

and this in my .git/config

[filter "strip-notebook-output"]
        clean = """jupyter nbconvert --ClearOutputPreprocessor.enabled=True --ClearMetadataPreprocessor.enabled=True --ClearMetadataPreprocessor.preserve_nb_metadata_mask=\"kernelspec\" --to=notebook --stdin --stdout --log-level=ERROR"""

It works well, except for the fact that if others clone my repo, they have to add the same lines to the .git/config.

My question is: is there a simple way to have this filter command automatically work when the repo is cloned?

Possibilities:

  • automatically add to the .git/config
  • somehow add the entire driver to the .gitattributes file
  • not quite as simple: use the nbstripout library instead of the one line command? (requires an install)
  • use a template directory (as described here)--this seems unnecessarily difficult with a single line command
0

There are 0 answers