Trying to pull a git repository using libgit2's example lg2_checkout

I am trying to pull a repository using libgit2 in C. The library provides an example (checkout.c) and its compiles without error.

When I launch the client without any parameter the print_usage informs me that a branch must be specified.

I have tried to check out the master branch (and not only this branch)

git_client checkout --git-dir C:\Users\me\cgit_test --progress --perf master

but I get this kind of error:

failed to resolve master: revspec 'master' not found
Bad news:
 revspec 'master' not found

How should or what should I specify for branch to be succesful in checkout?

Upvotes: 1

Views: 177

Answers (1)

Edward Thomson
Edward Thomson

Reputation: 78783

Do you have a branch named master? Or are you cloning a repository and it has a branch named master?

When you run git checkout, it will examine the remote branches, and create a local branch for you based on that. So if you clone a repository that has a branch foobar, you can run git checkout foobar.

When you do that, it will say:

branch 'foobar' set up to track 'origin/foobar'.
Switched to a new branch 'foobar'

libgit2's example code doesn't do that. It's not meant to be a complete re-working of the git CLI's "checkout" command, it's meant to walk you through the libgit2 API and show you how it works.

Upvotes: 0

Related Questions