The following bash script isn't meant to be run as a script. Rather, it's a reference for the commands that you'll want to copy and paste into the command line.
# Install XCode from app store if you haven't already
# Then install command-line tools
# You might get an error saying the packagew was not found on the update server
# If so, restart your computer and try again
xcode-select --install
# Install homebrew, this link is current as of 2014-10-8. Look here for latest: http://brew.sh/
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Download XQuartz from http://xquartz.macosforge.org/landing/
'DONT RUN THIS LINE ON THE COMMAND LINE
Now you have to install XQuartz and restart your computer'
# Run
brew update
brew doctor
# If brew doctor says `Your system is ready to brew`, then tab the osgeo brew pacakge...
brew tap osgeo/osgeo4mac
# And install QGIS 2.8, again, this information is current as of 2015-03-16.
# Check this repository to see if newer formulas exist: https://github.com/OSGeo/homebrew-osgeo4mac/tree/master/Formula
brew install osgeo/osgeo4mac/qgis-28
# If that went well, install pip
sudo easy_install pip
# QGIS requires some python packages at runtime, so install those
# Your QGIS installation messages will tell you this also, but it outputs a lot of text and it can be hard to tell what's a warning and what's required. You might have to install these as sudo.
pip install psycopg2
pip install pyparsing
# You might also have to install this too. Read what the qgis output says.
pip install matplotlib
# Put qgis in your **user's** Applications folder
# If you don't have this folder already, you'll want to run `mkdir /Users/<username>/Applications` first, or it will prompt you to do so if you try it and you don't have it
# If you want to put QGIS in your main applications folder, drop the `--local` flag
# Folks recommend putting QGIS in your local Applications folder so that's what I did
brew linkapps --local qgis-28
# First uninstall previous version, again, change the version based on what you have
brew uninstall qgis-24
# Install new version
brew install qgis-28
brew linkapps qgis-28 --local