When entering a repository which has just been created the HEAD
reference does not exist yet and "git read-tree -mu HEAD" would
complain loudly about that, giving a confusing error to users.
Avoid the error by checking the validity of HEAD before updating the
working tree.