brew update fails wtih fatal: could not read Username

Solution 1:

After trying to fix the gitconfig in my local I found out that actually brew was the issue.

For me homebrew-dupes and homebrew-versions caused the problem. But the fix is similar to taps.

Just do

brew tap

which gives you

...
homebrew/dupes
homebrew/versions
...

a simple untap

brew untap homebrew/dupes
brew untap homebrew/versions

after which everything is ok

brew update
Already up-to-date.