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;
评论完这2行后,它正在工作
注释
掉结帐选项后它起作用的原因是git_checkout_options
默认为结帐策略的试运行。 另一方面,GIT_CLONE_OPTIONS_INIT
将结帐策略初始化为GIT_CHECKOUT_SAFE
。您可以通过在结帐选项上设置策略来获得相同的行为:
clone_opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
相关文章:
- 使用libgit2、c++进行pull
- 在已经使用Git的情况下减少编译时间
- 使用Qt C++计算类似Git的SHA1哈希
- LibGit2 SSH身份验证失败
- 如何在c++中从git建立外部库
- 我应该将除 .cpp 以外的其他文件添加到 git 中吗?
- 从C++程序调用 git 克隆
- 使用 Git 处理 C++ Visual Studio 2019 解决方案的外部依赖项源代码管理的最佳方法是什么?
- 使用 libgit2 创建 NOT INITIAL 提交
- 更改 git 分支名称后,在项目的 Visual Studio 代码中丢失智能感知(建议,转到定义C++
- 如何组织 git 工作流以修复错误并同时引入新功能
- 使用 libgit2 从另一个分支创建新的 git 存储库?
- 如何在 libgit2 中设置结帐选项以使其表现得像"git checkout"
- 在libgit2中进行git描述
- git_clone() 克隆 .git 文件夹 (libgit2)
- 合并MERGE_HEAD后的Libgit2仍存在于.git文件夹中
- 使用libgit2进行Git Pull
- 如何使用libgit2从git存储库中的HEAD获取最后一次提交
- 使用libgit2从git存储库中删除文件
- 如何使用libgit2提交到git存储库