Skip to content

Instantly share code, notes, and snippets.

@rafi
Last active August 29, 2015 14:06
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 rafi/a97c50d0f964354e8362 to your computer and use it in GitHub Desktop.
Save rafi/a97c50d0f964354e8362 to your computer and use it in GitHub Desktop.
Git hooks maintenance
# Iterate and delete all hook files from git projects and submodules (only if there's ".git" in path)
find . -name 'post-*' | grep 'hooks/' | grep '.git' | sed 's/hooks\/.*$/hooks/g' | while IFS= read -r dir; do rm $dir/*; done;
# Copy your git template's hooks into all projects and submodules (only if there's ".git" in path)
find . -name 'hooks' -type d | grep '.git' | while IFS= read -r dir; do cp ~/.config/git/template/hooks/* $dir/; done;
# Copy your git template's hooks into a single project
cp ~/.config/git/template/hooks/* .git/hooks/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment