Merge pull request #1238 from nulltoken/fix/checkout-index checkout: Teach checkout to cope with orphaned Head