使用 libgit2 变基

问题描述

enter image description here

int rebase(const char *onto_str)
{
    git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;

    git_repository_head(&head,repo);
    git_annotated_commit_from_ref(&branch,repo,head);
    git_branch_lookup(&ref,onto_str,GIT_BRANCH_LOCAL);
    git_annotated_commit_from_ref(&onto,ref);

    git_rebase_init(&rebase,branch,onto,&opts);

    while ((rc = git_rebase_next(&op,rebase)) == 0)
        printf("%d\n",rc);

    printf("%d\n",rc);
}

在分支“new”上时,我执行 rebase master 并获得输出

0
-13

参考“新”现在 7fe5cbd 和工作目录包含来自 70d5af 的更改。 怎么了?分支“new”只改变一个文件,“master”改变另一个

解决方法

啊,我需要在一段时间内每一步都执行 git_rebase_commit() !