git_remote_connect总是返回错误

时间:2015-01-03 19:13:21

标签: c git libgit2

我是libgit2的新手。我的问题是关于git_remote_connect功能,这个问题让我困惑很多天。

当我使用git_remote_connect时,它总是返回错误,消息为:This transport isn't implemented. Sorry

代码看起来像:

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)); // git@github.com/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);
}

2 个答案:

答案 0 :(得分:1)

编译时不包括您要求libgit2使用的协议。为任何需要的包安装开发包/头文件并再次编译libgit2。 cmake输出会告诉你发现了什么;请参阅库的自述文件。

顺便说一下,git@github.com/github-username/Repo是一个本地路径,它始终可用,因此这不太可能是libgit2尝试使用的URL。

答案 1 :(得分:0)

您应该在 CMakeLists.txt 中启用 SSH

OPTION(USE_SSH              "Link with libssh2 to enable SSH support"        ON)
相关问题