Skip to content

Instantly share code, notes, and snippets.

@Bazze
Last active November 22, 2022 10:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bazze/870fee0bb38ca0917b3cffa21063b04d to your computer and use it in GitHub Desktop.
Save Bazze/870fee0bb38ca0917b3cffa21063b04d to your computer and use it in GitHub Desktop.
Bash script for setting up symlinked git hooks (that works)
#!/usr/bin/env bash
# 1. Save this script in your repo as "hooks/setup.sh"
# 2. Save your git hooks in "hooks/git/<hook name>"
# 3. Execute this script with bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${DIR}/.."
# Symlink git hooks
for filename in ${DIR}/git/*; do
filename=$(basename ${filename})
ln -s "../../hooks/git/${filename}" ".git/hooks/${filename}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment