To set up nbstripout as a git filter and diff driver, run the following commands in your repository. Replace /path/to/nbstripout with the actual path to the nbstripout executable.
To install for the current repository only:
git config filter.nbstripout.clean '/path/to/nbstripout'
git config filter.nbstripout.smudge cat
git config filter.nbstripout.required true
git config diff.ipynb.textconv '/path/to/nbstripout -t'
To install globally (for your user across all repositories), add the --global flag to the commands above.
To install system-wide (for all users), add the --system flag to the commands above.
After configuring git, you must tell git which files to use the filter on. Create a .gitattributes file (to version it with the repo) or edit .git/info/attributes (for the current repo only) with these lines:
*.ipynb filter=nbstripout
*.ipynb diff=ipynb
For global attributes, add those lines to ~/.config/git/attributes or $(prefix)/etc/gitattributes.
git config filter.nbstripout.clean '/path/to/nbstripout'
git config filter.nbstripout.smudge cat
git config filter.nbstripout.required true
git config diff.ipynb.textconv '/path/to/nbstripout -t'