Solution for an error with ‘brew update’ with merging files

When I tried updating homebrew/brew, the following error occurred:

brew update: The following untracked working tree files would be overwritten by merge


# cd /usr/local
# git fetch origin
# git reset --hard origin/master

as explained in the second answer, solved it. Source:

git – brew update: The following untracked working tree files would be overwritten by merge: – Stack Overflow.