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
@linssen
Copy link
Author

linssen commented Feb 19, 2014

Save to .git/hooks/post-commit and make executable chmod +x .git/hooks/post-commit.

http://stackoverflow.com/questions/1504724/a-git-hook-for-whenever-i-change-branches#answer-1810193

@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