I am trying to implement this solution, which implies creating a filter in git. I added these filters in .git/config
[core]
attributesfile = .gitattributes
[filter "nbstrip_full_test"]
clean = "echo Hello World .git/config"
smudge = cat
[filter "nbstrip_full"]
clean = "jq --indent 1 \
'(.cells[] | select(has(\"outputs\")) | .outputs) = [] \
| (.cells[] | select(has(\"execution_count\")) | .execution_count) = null \
| .metadata = {\"language_info\": {\"name\": \"python\", \"pygments_lexer\": \"ipython3\"}} \
| .cells[].metadata = {} \
'"
smudge = cat
required = true
and this in .gitattributes
*.ipynb filter=nbstrip_full_test
*.ipynb filter=nbstrip_full
However, when I commit or run git checkout jupyter/exploration.ipynb
, I don't see the filter being applied. What's wrong?
Find the setup in this test repo.
git version 2.39.2
To check whether the clean and smudge filters run, set the environment variable GIT_TRACE=1
. The output includes the filter commands that are invoked (see examples in the comments).
Note also that commands that look at working tree files, such as git add
and git diff
run the clean filters. Commands that copy data from the repository to the working tree, such as git checkout
, run the smudge filters.