'early EOF problem when installing Homebrew

I am trying to install Homebrew on Mac with the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 

Unfortunately, I am getting this error:

fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
Failed during: git fetch --force origin refs/heads/master:refs/remotes/origin/master

I tried many ways including:

git config --global core.compression 0
git fetch --unshallow

But they did not work. Also when I check the version of brew I got this:

Homebrew 3.4.1-9-g1447f08
Homebrew/homebrew-core (no Git repository)

It looks I have Homebrew but it doesn’t work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source