You can fix this issue by running two commands:
cd "$(brew --repo)" # Navigate to Homebrew's git repository
git prune && git gc # Remove loose objects
To check :
cd - # Go back to the original location
brew update
Output:
Already up-to-date.
Error should be fixed and gone! 🙂