checkout last branch from detached state code example Example: git return from detached head git checkout <branchname>