cd 'brew --prefix': no such file or directory
To do your cd command, you need to use backticks, not the quotation mark (putting this in an answer because difficult to format)

cd `brew --prefix`


The backticks make the shell execute the command and return the value. (in this case brew --prefix transforms into the directory where homebrew is installed).  For example, in a very simple case:

cd `echo '..'`


Transforms into:

cd ..


Which goes up a directory.

It looks like something is wrong with the git repo for your homebrew install. If you haven't installed a  lot, might be easier to just uninstall and reinstall and try again. You should go to the docs for brew, but you can just rm -rf on your Cellar folder and have everything return to its original state.  More info here.