Skip to content

Instantly share code, notes, and snippets.

@sigilioso
Last active December 11, 2015 20:19
Show Gist options
  • Save sigilioso/4654540 to your computer and use it in GitHub Desktop.
Save sigilioso/4654540 to your computer and use it in GitHub Desktop.
post-checkout hook to remove old pyc files and avoid errors
# post-checkout hook (on <path-to-project>/.git/hooks/post-checkout file)
# to avoid errors for old pyc files when checkout.
# Remember execution privileges (chmod +x <path-to-project>/.git/hooks/post-checkout).
#!/bin/bash
# Start from the repository root
cd ./$(git rev-parse --show-cdup)
# Delete pyc and empty directories
echo "[post-checkout] Deleting .pyc and empty directories"
find . -name "*.pyc" -delete
find . -type d -empty -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment