1

Does Jupyter Notebook store change history in .ipynb files?

I use Jupyter Notebook to develop an API client. It is much faster to run the code over and over again if I hardcode sensitive information. I am worry even if I clean up the code before I add to public repository, it may possible to trace back the old changes from a fresh copy of .ipynb file.

Example:

g = GenieClient('eb243592-faa2-4ba2-a551q-1brsf565c889') # (an invalid key for demonstration)
# g = GenieClient(input('OpsGenie API Key: '))
oliver nadj
  • 788
  • 7
  • 21

1 Answers1

2

.ipynb files don't seem to save the change history. Jupyter Notebooks can use checkpoint files to revert to a prior version, but the notebook itself doesn't contain that information. You should be fine if you leave out the checkpoint files or simply overwrite checkpoints with sensitive info. More information on checkpoints here: What are Jupyter Notebook checkpoint files for?

Mike Chen
  • 89
  • 7
  • Also: the ipynb file is human readable (sort of). So you can look at the file or "grep" it to see if it has something in it you don't want. This might be a good idea because sometimes there is stuff hidden in embedded HTML or javascript that is not always visible in the notebook. It is best to "restart and clear outputs" and then "save and close" before you commit an ipynb to a repository -- that will clean out everything except the basic content (but also things like matplotlib plots, unfortunately). – Aaron Watters Nov 28 '18 at 13:12