Skip to content

Instantly share code, notes, and snippets.

@linssen
Last active July 22, 2018 22:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save linssen/5729266 to your computer and use it in GitHub Desktop.
Save linssen/5729266 to your computer and use it in GitHub Desktop.
A post checkout hook to automatically remove *.pyc files.
#! /bin/sh
green='\033[0;32m'
nc='\033[0m'
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
# Delete .pyc files and empty directories.
echo "${green}Deleting PYC files...${nc}"
find . -name "*.pyc" -delete
find . -type d -empty -delete
echo "${green}Resetting submodules...${nc}"
git submodule foreach git reset --hard HEAD
git submodule update
@PatrickDRusk
Copy link

In your comment above, do you mean "post-commit"? Or maybe "post-checkout"?

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