首页 > 解决方案 > nbstripout: what does `diff=ipynb` do in .gitattributes?

问题描述

I'm using nbstripout to remove Jupyter output before committing. nbstripout generated a .gitattribute file that looks like this:

*.ipynb filter=nbstripout

*.ipynb diff=ipynb

This works as expected, whenever I git status, git diff, or git commit, it doesn't include Jupyter outputs. However, when I remove the second line, it does the same thing.

What does *.ipynb diff=ipynb do in this case?

标签: gitjupyter-notebook

解决方案


diff属性,当设置为字符串时,引用差异驱动程序。

但是第一个属性使用相同的命令引用内容过滤器驱动程序。
由于在执行 git diff(通过 smudge 命令)时涉及到内容过滤器驱动程序,因此它执行相同的操作(意味着与索引相比,它会更改工作树文件的内容)


推荐阅读