Notebooks in git
jOtter writes standard nbformat 4 JSON with the same layout as JupyterLab, so switching tools doesn’t cause noisy diffs. Its autosaves live in ~/.local/state/jotter/, never in your repository.
Notebooks as .py files
Section titled “Notebooks as .py files”If your repository keeps notebooks as scripts, so that outputs never reach git, jOtter opens and saves them directly: jotter analysis.py.
- A
.pyin jupytext’s percent format, with# %%cell markers as VS Code, Spyder and PyCharm write them, opens with its cells.# %% [markdown]blocks are markdown cells. Magics such as%matplotlib inlineare commented out in the file and uncommented in the cell, as jupytext does. - Any other
.pyopens as one code cell, and saves as a plain script again as long as it stays one cell.
A .py can’t hold outputs, execution counts or cell ids. Outputs stay in memory while jOtter is open: running cells doesn’t mark the notebook as modified, q quits without asking, and the autosave keeps them for crash recovery. To keep outputs, save as a notebook with :w analysis.ipynb; :w analysis.py converts the other way.
A file jupytext wrote is saved back byte for byte, with its header (the kernelspec and jupytext’s pairing settings) untouched, so a paired setup (jupytext --set-formats ipynb,py:percent) sees only the lines you changed. jOtter doesn’t add a header to a file that has none; the kernel then comes from --kernel or the usual lookup.
Not supported: jupytext’s other formats (light, Rmd, MyST) and marimo notebooks. Convert them with jupytext --to py:percent.
Clearing outputs before committing
Section titled “Clearing outputs before committing”Outputs, especially images, make diffs large. Press C to clear all outputs, then w to save. u brings them back if you change your mind.
To strip outputs automatically on every commit, use nbstripout:
pip install nbstripoutnbstripout --install # in the repository; adds a git filterYour working copy keeps its outputs; only the committed version is stripped.
Reading diffs
Section titled “Reading diffs”nbdime shows notebook diffs cell by cell instead of as raw JSON:
pip install nbdimenbdime config-git --enablegit diff notebook.ipynbCheckouts and merges
Section titled “Checkouts and merges”When git changes a notebook that’s open in jOtter, jOtter reloads it, or asks first if you have unsaved changes. See Data safety.