cmd/go: fix detached heads that are remnants of bad git clones.

Fixes issue 6042.

R=adg
CC=golang-dev
https://codereview.appspot.com/12923043