Git Hooks

Published: 2023-08-07


pre-commit

Clear outputs of Jupyter notebooks.

#!/bin/bash

# Stash unstaged changes
git stash -q --keep-index

# Clear notebook outputs
jupyter nbconvert --clear-output *.ipynb

# Stage updated files
git add -u

# Re-apply original unstaged changes
git stash pop -q

  1. code
  2. jupyter