Skip to content

Instantly share code, notes, and snippets.

@cowboy
Forked from miketaylr/pre-commit
Created January 5, 2012 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cowboy/1566697 to your computer and use it in GitHub Desktop.
Save cowboy/1566697 to your computer and use it in GitHub Desktop.
#!/bin/bash
# pre-commit hook to prevent html5 video or audio files from being checked
# into the repo. because large binary files in a git repo sucks. bad.
media_files=$(git diff --cached --name-only --diff-filter=ACR | \
egrep -i '\.(webm|mp4|ogg|mp3|ogv|m4v|avi|vp8|mov|oga|mp1|mp2|mpeg|3gp|wav)$')
if [[ "$media_files" ]]; then
echo 'Commit failed. Are you trying to check in media files into the repo?'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment