fix 1372 due to git HEAD file corrupted issue

In case of HEAD file corrupted, we simply delete and `git init`.