Copy this script to ".git/hooks/post-checkout" in your repository and make it executable:
chmod +x .git/hooks/post-checkout
Tweak it at will. I'm refreshing the bundle and restarting the app server because the Gemfile is different on my "hosted" branch than on other branches.