Search code examples
cgitlibgit2

git_remote_connect always return wrong


i'm new in libgit2. and my problem is about git_remote_connect function, this problem has been confusing me for many days.

when i use git_remote_connect, it always return wrong, the message is:This transport isn't implemented. Sorry

The code is simply looks like:

git_remote *remote = NULL;
git_remote_load(remote, git_repo, remote_name);

// output the correctly result, just like run: git remote -v
g_message("remote user:", git_remote_name(remote)); // github-username
g_message("remote url:", git_remote_url(remote)); // [email protected]/github-username/Repo

if (git_remote_connect(remote, GIT_DIRECTION_FETCH) < 0) {
    const git_error *e = giterr_last();
    g_error("connect wrong!\n"
            "message: %s",
            e->message);
}

Solution

  • The protocol you're asking libgit2 to use was not included while compiling. Install the development package/headers for whatever package is needed and compile libgit2 again. The cmake output will tell you what was discovered; see the README for the libraries.

    As an aside, [email protected]/github-username/Repo is a local path, which is always available, so it's unlikely that this is the URL which libgit2 is trying to use.