If you buy a new Macbook Air or Pro, you will probably install homebrew.
But if you are living in some region where some web services can’t be accessed, you need to find an alternative source to install homebrew.
In this case, it showed “Failed to connect to raw.githubusercontent.com”. This error means you can’t access raw.githubusercontent.com.
As an alternative, you can find many mirrors as shown below.
Tsinghua University: cd “$(brew –repo)” && git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git