This can be added to git as a post-checkout hook: In your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';'