Skip to content

Instantly share code, notes, and snippets.

@ObiWahn
Created July 12, 2017 09:34
Show Gist options
  • Save ObiWahn/fb043f12fc8ffd4a142cbd6f7c41a9c4 to your computer and use it in GitHub Desktop.
Save ObiWahn/fb043f12fc8ffd4a142cbd6f7c41a9c4 to your computer and use it in GitHub Desktop.
use git hooks with templates

create and register git template directory

> mkdir -p ~/.git-templates/hooks
> git config --global init.templatedir '~/.git-templates'

add some example pre-push hook

> cat > ~/.git-templates/hooks/pre-push << EOF
#!/bin/bash
script='./utils/jslint.sh'
if [ -e \$script ]; then
  echo "running jslint"
  \$script
  exit \$?
fi
exit 0
EOF
chmod 755 ~/.git-templates/hooks/pre-push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment