git-clone - 在 libgit2 的 git_clone 中在哪里设置用户名和密码?

标签 git-clone libgit2

您好,问题是,当我使用libgit2克隆一个repo时,会出现:“发送请求失败:发生安全错误”,代码为:

#include <windows.h>
#include "include/git2.h"

#pragma comment(lib, "git2.lib")

int main(int argc, char* argv[])
{
    git_threads_init();

    git_repository* repo = NULL;
    git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
    int iRetVal;

    opts.bare = true;
    iRetVal = git_clone(&repo, "https://github.com/libgit2/libgit2.git", "C:\\test", &opts);
    if( (iRetVal < 0) && (giterr_last() != NULL) )
    {
        MessageBox(NULL, giterr_last()->message, "gittest", MB_ICONERROR | MB_OK);
    }
    if( repo != NULL )
        git_repository_free(repo);

    git_threads_shutdown();
    return 0;
}

libgit2 版本是 0.21.2

最佳答案

您必须填写 remote_callbacks git_clone_options 的属性(property).

那些 online::clone.c tests 如果您开始使用,它将执行经过身份验证的克隆。

关于git-clone - 在 libgit2 的 git_clone 中在哪里设置用户名和密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27196152/

相关文章:

git clone 无法访问 docker 容器内的主机

c - libgit2 中的 git_sysdir_find_in_dirlist() 是做什么的?

python - 使用 Pygit2 实现拉取

git - 如何自动化git在服务器上自动克隆一个repo?

git - 在执行 git clone --mirror 时,实际文件在哪里?

Git克隆导致文件被删除和未跟踪

libgit2 - 我们如何在 Visual Studio 2010 Windows 应用程序中集成 Libgit2 库

gitlab: git clone https with large repos 失败

c# - 进行并行阶段的最佳方法?

c - libgit2:获取后如何合并和提交?