Fix clone fail if repo head detached

Set head detach if can't found branch after download

Signed-off-by: Frank Li <lznuaa@gmail.com>