Finally, I find the right way to use homebrew.
- Let http requests of git go through a socks5 proxy
git config --global http.proxy 'socks5://127.0.0.1:1081'
- Since homebrew doanloads files using curl, set a socks proxy for curl: just add
proxy=socks5://127.0.0.1:1081
to~/.curlrc
.
Too much time has been wasted because of the poor network.