## TL;DR
Every committed execution bakes base64 images, widget state, and dataframes into git history, and a 50MB notebook makes every clone and diff painful. Strip outputs before committing with a pre-commit hook or a `git clean` filter so the repo stores code, not results. For history that is already bloated, rewrite it with a history-editing tool after coordinating with the team, since rewriting history changes commit hashes for everyone.

```text
agent committed the executed notebook with 50MB of outputs: repo bloated
```

## Use this when
- `git clone` or `git pull` is slow and `git log` shows huge notebook blobs.
- Diffs on notebooks are unreadable walls of base64 output.
- An agent's automation commits executed notebooks as run artifacts.

## Not for this skill when
- The notebook file is large because of long source cells. That is a code-organization problem.
- You need executed outputs versioned as review artifacts. Then store them as build artifacts, not in git.

## Steps
1. Measure the damage: `git log --name-only --pretty=format: | sort | uniq -c | sort -rn | head` plus `git rev-list --objects --all | grep ipynb` sized output, or simply `du -sh` the notebook. Expected: you know which notebooks and commits carry the weight.
2. Strip outputs from the working tree: `jupyter nbconvert --to notebook --ClearOutputPreprocessor.enabled=True --inplace notebook.ipynb`. Expected: the file shrinks dramatically and still opens.
3. Install a pre-commit hook that strips outputs on every commit (the `nbstripout` package does this as a git filter). Expected: `git diff --cached` on a notebook shows code changes only.
4. Verify the hook: execute the notebook, then `git add` and `git diff --cached`. Expected: outputs are absent from the staged diff even though the working file has them.
5. For existing history, coordinate a history rewrite with the team (everyone re-clones after), using a filter tool to strip outputs from all historical blobs. Expected: the repo size drops and all collaborators are on the rewritten history.
6. Move run artifacts out of git: have the agent write executed notebooks to artifact storage or a dated outputs directory that is git-ignored. Expected: future runs never re-bloat the repo.

## Tool compatibility
git 2.x; nbstripout; nbconvert 7.x ClearOutputPreprocessor; pre-commit framework.

## Variant phrasings
### notebook outputs committed git repo huge
The bloat phrasing. Strip outputs with a clean filter and repair history.

### git repo bloated by ipynb outputs
The history phrasing. The fix is two-part: stop the bleeding with hooks, then rewrite history.

### nbstripout pre-commit hook notebook
The tooling phrasing. nbstripout as a git filter is the standard prevention.

## Why it happens
Notebook outputs are not source code: images, widget state, and rich tracebacks are bulky, binary-ish JSON that git cannot delta efficiently, so each committed execution adds nearly its full size to history forever. Agents make this worse because they commit after every run without the human habit of clearing outputs first. A clean filter fixes the workflow at the source by stripping outputs at commit time while leaving the working file executable. History repair is the painful second half, needed because git's immutability means the bloat stays in every clone until the history itself is rewritten.

## Edge cases / pitfalls
- Rewriting published history breaks every open PR and every collaborator's checkout. Announce it, pick a quiet window, and verify everyone re-clones.
- Stripping outputs also strips the `parameters` cell injected values papermill needs at read time. Keep parameter defaults in source; never depend on committed execution state.
- Some teams genuinely review outputs in PRs. For them, render executed notebooks as HTML artifacts in CI instead of committing the ipynb outputs.
- Widget state can be enormous even with modest outputs. The clean filter should strip widget metadata too, or one dashboard notebook re-bloats the repo.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_xtbWxXHT2BTrXgqod62oPw
