Long story short: we're using Jupyter notebooks (.ipynb
files) and have set up the Jupyter config to save .py
copies (à la this answer on SO, for the purposes of nicer git diffs).
So every time I save a .ipynb
file, it saves a .py
version, with otherwise the same filename. If no .py
version already existed, it creates a new one.
Is it possible to automatically add / track these newly created .py
files, perhaps by putting something in the git config?
Edit
So this may be possible using a git pre-commit hook, having read up about it. However, I don't really know enough to write a hook from scratch.
To reiterate what I want: I save foo_bar.ipynb
, automatically creating foo_bar.py
. I want the pre-commit hook to add foo_bar.py
if I do, e.g., git commit -a
. To emphasise, I don't want it to add any old .py
files, only ones that have the same filename as an existing .ipynb
file.