code: def _safe_issue_checkout(repo, issue=None):
      
      branch_name = str(issue) if issue else 'master'
      if branch_name not in repo.heads:
          branch = repo.create_head(branch_name)
      else:
          branch = repo.heads[branch_name]
      branch.checkout()
docs: Safely checkout branch for the issue.