Skip to content

Instantly share code, notes, and snippets.

@nwjlyons
Created May 15, 2014 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjlyons/c520ec34301b8e4ed959 to your computer and use it in GitHub Desktop.
Save nwjlyons/c520ec34301b8e4ed959 to your computer and use it in GitHub Desktop.
Delete .pyc files and empty directories on git checkout
#! /bin/sh
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
# Delete .pyc files and empty directories.
find . -name "*.pyc" -delete
find . -type d -empty -delete
echo "$(tput bold).pyc files and empty directories deleted.$(tput sgr0)"
@nwjlyons
Copy link
Author

Create file .git/hooks/post-checkout and paste this gist. File needs to be executable chmod +x .git/hooks/post-checkout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment