title: How to check out a branch with GitPython
body: <p>I have cloned a repository with GitPython, now I would like to checkout a branch and update the local repository's working tree with the contents of that branch. Ideally, I'd also be able to check if the branch exists before doing this. This is what I have so far:</p>
  
  <pre><code>import git
  
  repo_clone_url = "git@github.com:mygithubuser/myrepo.git"
  local_repo = "mytestproject"
  test_branch = "test-branch"
  repo = git.Repo.clone_from(repo_clone_url, local_repo)
  # Check out branch test_branch somehow
  # write to file in working directory
  repo.index.add(["test.txt"])
  commit = repo.index.commit("Commit test")
  </code></pre>
  
  <p>I am not sure what to put in the place of the comments above. The <a href="http://gitpython.readthedocs.io/en/stable/tutorial.html#switching-branches" rel="noreferrer">documentation</a> seems to give an example of how to detach the HEAD, but not how to checkout an named branch.</p>