Homebrew installation failed

I was trying to re-install homebrew on my Mac. I used the following command.

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

I got the following error. Could someone help me with what to do here?

==> Checking for `sudo` access (which may request your password).
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /usr/sbin/chown -R aryan:admin /usr/local/Homebrew
==> Downloading and installing Homebrew...
HEAD is now at 227445ece Merge pull request #11288 from Homebrew/update-manpage
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Failed during: /usr/local/bin/brew update --force --quiet

Solution 1:

I removed the HomeBrew files by running the following command. After that, I ran the installation as mentioned in the above post. It all worked fine. I was able to install all the packages I need.

sudo rm -rf /usr/local/HomeBrew