#!/bin/bash

# Find the location of the script.
HOOKS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "Creating and registering symbolic links in .git/hooks..."
rm -rf "$1/.git/hooks"
ln -is "$HOOKS_DIRECTORY" "$1/.git/hooks"
git config --global hooks.symlinksourcerepo "$HOOKS_DIRECTORY"

echo "...done"

#!/bin/bash

# Find the location of the script.
HOOKS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "Creating and registering symbolic links in .git/hooks..."
if [[ -d "$1/.git/hooks" || -L "$1/.git/hooks" ]]; then
	if [[ -d "$1/.git/hooksOLD" || -L "$1/.git/hooksOLD" ]]; then
		rm -rf "$1/.git/hooksOLD"
	fi
	echo "Backing up $1/.git/hooks to $1/.git/hooksOLD"
	mv -f "$1/.git/hooks" "$1/.git/hooksOLD"
fi
ln -is "$HOOKS_DIRECTORY" "$1/.git/hooks"
git config --global hooks.symlinksourcerepo "$HOOKS_DIRECTORY"

echo "...done"

Backup old hooks directory before overwriting
Backup old hooks directory before overwriting
