Skip to content

Instantly share code, notes, and snippets.

#/usr/bin/env bash
git config --global init.templatedir '~/.git-templates' && \
mkdir -p ~/.git-templates/hooks && \
cd ~/.git-templates/hooks
cat >post-checkout <<'EOL'
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2" || true