Skip to content

Instantly share code, notes, and snippets.

@joncotton
Last active January 30, 2018 05:52
Show Gist options
  • Select an option

  • Save joncotton/4660441 to your computer and use it in GitHub Desktop.

Select an option

Save joncotton/4660441 to your computer and use it in GitHub Desktop.
Git hook to remove *.pyc files and empty directories. Put in `.git/hooks/post-checkout` and chmod +x to make it run.
#! /bin/sh
echo "Purging pyc files and empty directories..."
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
# Delete .pyc files, empty directories and MacOS cruft
find . -name '*.pyc' -delete 2>&1 > /dev/null &
find . -type d -empty -delete 2>&1 > /dev/null &
find . -type f -name '.DS_Store' -delete 2>&1 > /dev/null &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment