Skip to content

Instantly share code, notes, and snippets.

@rafeca
Created November 30, 2012 12:39
Show Gist options
  • Save rafeca/4175527 to your computer and use it in GitHub Desktop.
Save rafeca/4175527 to your computer and use it in GitHub Desktop.
Pre-commit hook to alert the committer before committing changes dangerous files. Save it in .git/hooks/pre-commit
#!/bin/sh
FILES="app/config/config.production.yaml\|app/config/application.production.yaml"
if [ "`git diff-index --cached HEAD | grep \"$FILES\"`" ]; then
exec < /dev/tty
echo "You are commiting changes to a live config file. Are you sure? [y/n] "
read -s -n 1 sure
if [[ $sure == "y" ]]; then
exit 0
else
echo "Aborting commit..."
exit 1
fi
fi
@alexmiddeleer
Copy link

Works well, thanks for posting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment