I'm trying to do branch switching using libgit2. Repo already cloned and references to existing remote branches created.
If I put GIT_CHECKOUT_FORCE to checkout_strategy, it works as expected - create missing, modify existing, delete removed.
If GIT_CHECKOUT_RECREATE_MISSING - create missing only.
If GIT_CHECKOUT_SAFE - do nothing. Am I missing something?
git_reference_lookup(&branch_ref, repo, ref_name);
git_repository_set_head(repo, git_reference_name(branch_ref));
git_reference_symbolic_create(&head, repo, "HEAD", git_reference_name(branch_ref), 1, NULL);
git_checkout_head(repo, &opts);
I got branches
- master (current): f1.txt f2.txt
- new: f1.txt (content differs from master's one)
After GIT_CHECKOUT_SAFE to new:
- f1.txt (content from master)
- f2.txt (staged to commit)