Skip to content

Instantly share code, notes, and snippets.

@FiXato
Created January 15, 2009 11:55
Show Gist options
  • Save FiXato/47377 to your computer and use it in GitHub Desktop.
Save FiXato/47377 to your computer and use it in GitHub Desktop.
Switch between github branches and change the rails database.yml
#!/bin/sh
# Usage: switch2branch branchname
# Easily switch between branches and their databases for Rails projects.
# Checks out given branch and copies the branch's database.yml to the active database.yml
# Outputs a small list of databases being used.
# Make sure you have set up your branch's database.yml in #{RAILS_ROOT}/config/database.branch.#{branchname}.yml
git checkout $1 && cp ./config/database.branch.$1.yml ./config/database.yml
echo Using:
egrep "^\\w+:|database:" config/database.yml | sed s/database:/\ /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment