Fix fail clone local repo which head detatched

Set head detach if can't found branch after download

Signed-off-by: Frank Li <lznuaa@gmail.com>