AboutBlogMediaTags

Understanding `.ipynb_checkpoints`: What they are and how to manage them

Runcell Team,

TL;DR


What is .ipynb_checkpoints?

When you open and save a Jupyter Notebook, Jupyter keeps lightweight snapshots (checkpoints) of your work. These are stored in a hidden directory named .ipynb_checkpoints in the same folder as your notebook(s).

A typical structure looks like this:

project/ ├─ data/ ├─ analysis/ │ ├─ exploration.ipynb │ ├─ model.ipynb │ └─ .ipynb_checkpoints/ │ ├─ exploration-checkpoint.ipynb │ └─ model-checkpoint.ipynb └─ README.md

Each *-checkpoint.ipynb is a JSON notebook file, just like your main .ipynb, but captured at a previous point in time.

Are checkpoints the same as autosave?

Not exactly.

Front‑end behavior varies slightly:


Why do they keep reappearing?

Because they’re part of Jupyter’s safety net. Even if you delete the folder, Jupyter will recreate it the next time it saves a checkpoint for that directory. That’s by design.


Is it safe to delete them?

Yes. Deleting .ipynb_checkpoints does not remove your main notebook; it only removes the snapshots. You’ll lose the quick “revert” option for those notebooks until new checkpoints are created.

Good times to delete:


Keep them out of Git (and friends)

Checkpoints don’t belong in version control—Git already provides version history. Add these rules to your ignore files:

.gitignore

# Jupyter Notebook checkpoints .ipynb_checkpoints/ **/.ipynb_checkpoints/ *-checkpoint.ipynb

.dockerignore

.ipynb_checkpoints/ **/.ipynb_checkpoints/ *-checkpoint.ipynb

The double‑star ensures nested directories are covered. The file pattern is a belt‑and‑suspenders to catch any stray checkpoint files that may have been copied out of the folder.

If you use pre‑commit, you can also enforce cleanup:

# .pre-commit-config.yaml repos: - repo: local hooks: - id: clean-ipynb-checkpoints name: Remove Jupyter checkpoints language: system pass_filenames: false entry: bash -c 'find . -name "*-checkpoint.ipynb" -delete && find . -type d -name ".ipynb_checkpoints" -empty -delete'

Clean up checkpoints safely

Linux/macOS (bash)

Delete only checkpoint files:

find . -name "*-checkpoint.ipynb" -delete

Remove empty .ipynb_checkpoints folders afterward:

find . -type d -name ".ipynb_checkpoints" -empty -delete

Windows (PowerShell)

Get-ChildItem -Recurse -Filter *-checkpoint.ipynb | Remove-Item Get-ChildItem -Recurse -Directory -Filter .ipynb_checkpoints | Remove-Item -Recurse -Force

Tip: Prefer deleting files first, then removing now‑empty directories. This minimizes the chance of deleting unrelated content if paths were nested in unexpected ways.


Reverting to a checkpoint

If you haven’t deleted them yet:

If the option is disabled or empty, there are no checkpoints yet for that notebook.


Autosave and configuration tips

There isn’t a universally supported, single “disable checkpoints forever” switch. The safest pattern is to ignore and clean them rather than trying to disable the mechanism.


CI/CD & packaging


Security & privacy notes


FAQ

Q: My repo keeps showing new *-checkpoint.ipynb files even with .gitignore. Why? A: They were likely committed before the ignore rule existed. Remove them from the index:

git rm -r --cached . git add . git commit -m "Stop tracking Jupyter checkpoints"

Q: Can I use checkpoints as ‘real’ versioning? A: They’re best for local, short‑term rollback, not for collaboration history. Use Git (optionally with tools like nbdime) for meaningful diffs and merges.

Q: Do other notebook tools create the same folder? A: Not all. Behavior depends on the front‑end. Jupyter’s classic UI and JupyterLab commonly do; others may rely on different backup systems.


That balance gives you fast local safety with clean, lightweight repositories.

© Runcell.RSS