Install XCode from the Mac App store (you need a valid apple account to do so).
Open it up and accept the terms and conditions. Go to XCode > Preferences > Downloads
and install from Components the Command Line Tools
package.
Install Homebrew with:
~$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
If the installation was successfull, verify: