TLDR version, if you have homebrew
xcode-select --install ; brew tap homebrew/versions ; brew tap homebrew/dupes \ brew install apple-gcc42 ; brew link apple-gcc42
xcode-select --install is how you (re)install the mavericks xcode 5 CLI tools, you HAVE to do that. Either way, you should make sure you have CLI tools installed.
NB: apple-gcc42 is quite old, but doesn't require a build from source (so it can work right away). Those who have a bit more patience and want a more modern GCC can use
brew install gcc48 or the like (though the build may take a while)