title: Checkout branch with libgit2
body: <p>I'm trying to implement a simple checkout operation between 2 branches. The code executes without errors.</p>
  
  <pre><code>git_libgit2_init();
  git_object *treeish = NULL;
  git_checkout_options opts;
  opts.checkout_strategy = GIT_CHECKOUT_SAFE;
  
  /* branchName in this case is "master" */
  handleError(git_revparse_single(&amp;treeish, repo, branchName));
  handleError(git_checkout_tree(repo, treeish, &amp;opts));
  
  git_object_free(treeish);
  git_libgit2_shutdown();
  </code></pre>
  
  <p>However, the branch does not change when I check it using <code>git status</code>.
  I've checked the <a href="https://libgit2.github.com/docs/guides/101-samples/" rel="nofollow noreferrer">101 examples of libgit2</a> and it says:</p>
  
  <blockquote>
    <p><code>git_checkout_options</code> isn’t actually very optional. The defaults won’t
    be useful outside of a small number of cases. The best example of this
    is checkout_strategy; the default value does nothing to the work tree.
    So if you want your checkout to check files out, choose an appropriate
    strategy.</p>
    
    <p><code>NONE</code> is the equivalent of a dry run; no files will be checked out.</p>
    
    <p><code>SAFE</code> is similar to <code>git checkout</code>; unmodified files are updated, and modified files are left alone. If a file was present in the old HEAD
    but is missing, it’s considered deleted, and won’t be created.</p>
    
    <p><code>RECREATE_MISSING</code> is similar to <code>git checkout-index</code>, or what happens after a clone. Unmodified files are updated, and missing files are
    created, but files with modifications are left alone.</p>
    
    <p><code>FORCE</code> is similar to <code>git checkout --force</code>; all modifications are overwritten, and all missing files are created.</p>
  </blockquote>
  
  <p>In my case I'm testing it with a very small repo without uncommited changes and without any conflicts between these 2 branches.</p>
  
  <p><a href="https://i.stack.imgur.com/6Iggl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Iggl.png" alt="git log"></a></p>
  
  <p>What am I doing wrong? I expected this code to do something like <code>git checkout master</code></p>