我正在使用 libgit2 v0.23.0 库进行 git pull 和提交操作。我正在调用git_merge(repo,their_heads,1,&merge_opt,&checkout_opts);方法,它工作正常并将更改从远程存储库合并到本地存储库。但是之后,当我调用git_commit_create()方法时,它会抛出错误failed to create commit: current Tip is not the first Parent ,错误代码为-15。
我调查并发现 FETCH_HEAD 和 MERGE_HEAD 文件包含更新的 oid,但 ORIG_HEAD 仍然包含以前/过时的 oid。我不确定这是我在 git_commit_create() 期间遇到的错误的原因。
int fetch()
{
qDebug()<<"Fetch";
git_remote *remote = NULL;
const git_transfer_progress *stats;
struct dl_data data;
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
git_repository *repo = NULL;
QString repoPath = "repopath/.git";
int error = git_repository_open(&repo, repoPath.toStdString().c_str());
if (git_remote_lookup(&remote, repo, "origin") < 0) {
if (git_remote_create_anonymous(&remote, repo,"repoURL") < 0) …Run Code Online (Sandbox Code Playgroud) libgit2 ×1