"fatal: Not a valid object name develop" error when running brew upgrade/cleanup
It seems that the error has been caused by a misbehaving tap. After I've cleaned up taps with

brew untap &lt;tapname&gt;


the error disappeared.

P.S. to list all installed taps, just run:

brew tap