code: def checkout(self, branch_name):
          
          try:
              find(
                  self.repo.branches, lambda b: b.name == branch_name
              ).checkout()
          except OrigCheckoutError as e:
              raise CheckoutError(branch_name, details=e)
docs: Checkout a branch by name.