Skip to content

Instantly share code, notes, and snippets.

@mckeed
Created June 8, 2012 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mckeed/2897878 to your computer and use it in GitHub Desktop.
Save mckeed/2897878 to your computer and use it in GitHub Desktop.
A useful post-merge git hook for Rails projects. Automatically runs bundle install and rake db:migrate. Put it in .git/hooks
#!/bin/bash
if [ ! -z `git diff --name-only HEAD@{1}..HEAD Gemfile` ]
then
echo -e "\033[0;31m*** Gemfile change detected, running bundle install ***\033[0m"
bundle install
fi
if [ ! -z `git diff --name-only HEAD@{1}..HEAD db/migrate` ]
then
echo -e "\033[0;31m*** Migration changes detected, running rake db:migrate ***\033[0m"
rake db:migrate
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment