fix 1372 due to git HEAD file corrupted issue

In case of HEAD file corrupted, we simply delete the HEAD file and run `git init`.
I'd add an additional comment:
`// we've since this issue on a few occasions but don't really understand what causes it`