Skip to content

Instantly share code, notes, and snippets.

@jamesfolberth
jamesfolberth / pre-commit
Created March 8, 2019 04:41
Simple git pre-commit hook that checks IPython/Jupyter notebooks for output
#!/bin/sh
# Check for .ipynb files with output cells;
# ask the user if they really want to commit them
ipynb_files=`git diff --staged --name-only | awk "/.ipynb/"`
have_output=""
if [ -n "$ipynb_files" ]; then
while read filename; do
if [ $(git show :$filename | grep -cm1 "\"output_type\":") -ge 1 ]; then