I woke up yesterday annoyed with the lack of git in my python-notebook-life so I built this…
I’d love it if anyone wanted to play with and give feed back.
The readme probably explains it better than I can here. Let me know if you have questions.
Its pretty simple and not 100% complete but it does everything you’d need it too. The only missing feature is a converter from the python files back to notebooks, but you don’t need that really and it is to come.
I should say… I know others have built things, probably pretty similar but I liked the simplicity of this setup.
There’s a longer answer that has more to do with my suggested workflow, but I need to run. I’ll update this thread and the readme once I’ve thought about it some more.
SIDE NOTE: I’ve added the above package to pip and in the process moved from nbgit to nb_git.
Hi Everyone - In thinking through the above promised “longer answer” for Jeremy I decided to rework the whole thing. I am really excited about how it worked out.
will automatically track every notebook in your repo. This is similar to my original setup (but works better).
However the default is much more “git” like, where you choose what notebooks to track and can review and diff files before committing your changes.
An example workflow might be:
# add a notebook to be tracked
gitnb add SomeNotebook.ipynb
# check the changes before commiting
gitnb diff SomeNotebook.ipynb
# commit your changes
gitnb commit -am "I fixed a bug"
The README has a fairly complete set of docs with examples. Please let me know if you have any questions, if you hate it , if you love it, if you want to contribute, etc…
Awesome work.
How hard would it be to have something like git gutter (https://github.com/jisaacks/GitGutter) inside a jupyter notebook now that you have done this?
Thats a cool little plugin. I hadn’t seen it before.
Sadly I don’t think gitnb would help you get that into a python-notebook. For gitnb diff I first generate a temporary “nbpy.py” version of the notebook, then diff that ( using the difflib module ) with the saved ( ie gitnb update-ed ) version of the file.
I could imagine a similar process that then injected the diff markers into the ipynb file, but (a) thats probably a terrible idea, and (b) to do something like GitGutter you would probably really want to inject into the html. With that in mind would probably need to be something done deep inside of the core of jupyter’s platform.
So yeah - a command line gitnb diff is probably your best bet for now, but of course I could be missing something.