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`.