Last Updated: February 25, 2016
· MeetDom

Updating homebrew with untracked changes error

Today I tried to upgrade my local PostgreSQL server to 9.3.1 and encountered an error while trying to update homebrew on my Mac:

~$ brew update
error: The following untracked working tree files would be overwritten by merge:
Please move or remove them before you can merge.

Issuing the brew doctor command revealed uncommitted modifications. Since homebrew is a Git repository, I had to update or reset brew to the master branch version. I didn't make any intentional changes to the repository, so I skipped stashing the changes and went with a hard reset:

~$ cd /usr/local
/usr/local$ git fetch origin
/usr/local$ git reset --hard origin/master

For those that care, the first command changes directory to the homebrew location on your machine. The second command updates your local version with the remote branch. Lastly, the local branch is reset , which means the SHA of the HEAD reference is changed to match the origin/master. I found this documentation about Git resets very useful.

If you encounter an error when trying to fetch the origin (I didn't), it may be because it hasn't been added, in this case you may need to add it:

~$ cd /usr/local
/usr/local$ git fetch origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
/usr/local$ git remote add origin

I was at stumped at first and had to dig around for info so I'd like to thank the others for passing on the info I found.

Say Thanks