how to clone specific tag using git_clone() in libgit2

半城伤御伤魂 提交于 2019-12-25 11:49:48

问题


I want to clone specific tag from my repository in bitbucket. Now I am able to clone just the whole repository. What should I add to my code to clone specific tag?

I have seen this but it doesnt really helped me :

https://github.com/libgit2/git2go/issues/126


git_libgit2_init();

int num = 0;

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_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();


Thanks for your time

来源:https://stackoverflow.com/questions/43184520/how-to-clone-specific-tag-using-git-clone-in-libgit2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!