繁体   English   中英

git_clone()仅克隆.git文件夹(libgit2)

[英]git_clone() clone just .git folder (libgit2)

当我执行git_clone()时,它可以成功运行,但是仅克隆.git文件夹。 当我使用

git clone http:/url.adress.com/myRemoteRepo C:/ destination / to / clone

在终端中,它还会克隆另一个文件夹,而不仅仅是.git文件夹,我希望git_clone()那样工作,这可能吗?

我的代码:

  int num=0;

git_libgit2_init();

git_repository *cloned_repo = NULL;

int error = git_clone(&cloned_repo, all_urls.at(num).c_str(), clone_to.at(num).c_str(), &clone_opts); 

if (error != 0) {

    const git_error *err = giterr_last();

    cerr << "error in clone num " << num << " -> message :" << err->message << endl;

}

else cout << endl << "Clone " << num << " succesful" << "(from url : " << all_urls.at(num) << "    " << "to path : " << clone_to.at(num) << ")" << endl;

git_repository_free(cloned_repo);

git_libgit2_shutdown();

这是我设置选项的方式

git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
        // git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
        // clone_opts.checkout_opts = checkout_opts;
        clone_opts.fetch_opts.callbacks.credentials = cred_acquire_cb;

在评论这两行之后,它就可以了

注释掉签出选项后,它起作用的原因是git_checkout_options默认签入策略为git_checkout_options运行。 GIT_CLONE_OPTIONS_INIT ,在另一方面,初始化校验策略, GIT_CHECKOUT_SAFE 您可以通过在结帐选项上设置策略来获得相同的行为:

clone_opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM