이 게시물 (libgit2 (fetch & merge & commit))의 답변을 살펴 봤지만 힘내 당기기를 사용하는 데 어려움을 겪고 있습니다. 오류 메시지가 표시되지 않습니다. 가져 오기는 작동하지만 병합은 발생하지 않습니다. 내가 그 병합 작동하지 않는 원인을하고있는 중이 야 무엇libgit2를 사용하여 힘내 당기기
static int fetchhead_ref_cb(const char *name, const char *url,
const git_oid *oid, unsigned int is_merge, void *payload)
{
if (is_merge)
{
strcpy_s(branchToMerge, 100, name);
memcpy(&branchOidToMerge, oid, sizeof(git_oid));
}
return 0;
}
void GitPull()
{
git_libgit2_init();
git_repository *repo = NULL;
git_remote *remote;
int error = git_repository_open(&repo, "C:\\work\\GitTestRepos\\Repo1");
CHECK_FOR_ERROR
error = git_remote_lookup(&remote, repo, "origin");
CHECK_FOR_ERROR
git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
error = git_remote_fetch(remote, NULL, &options, NULL);
CHECK_FOR_ERROR
git_repository_fetchhead_foreach(repo, fetchhead_ref_cb, NULL);
git_merge_options merge_options = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
git_annotated_commit *heads[ 1 ];
git_reference *ref;
error = git_annotated_commit_lookup(&heads[ 0 ], repo, &branchOidToMerge);
CHECK_FOR_ERROR
error = git_merge(repo, (const git_annotated_commit **)heads, 1, &merge_options, &checkout_options);
CHECK_FOR_ERROR
git_annotated_commit_free(heads[ 0 ]);
git_repository_state_cleanup(repo);
git_libgit2_shutdown();
}
...
On branch Branch_1_1.
Your branch is behind 'origin/Branch_1_1' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean
내 코드는 다음과 같습니다 ... 힘내 상태 내 지점 1 커밋에 의해 뒤에 것을 보여준다 이렇게?
감사합니다. Jason. 나는 커밋을하기 위해 당신의 제안을 시도했다. 로컬 브랜치와 리모트 브랜치를 모두 부모로 지정하지만, 로컬 리포는 리모컨보다 먼저 커밋됩니다. 리모컨은 "git pull"과 함께 발생하지 않습니다. – Anthony
로컬 분기 * 병합 후 커밋해야합니다. 그러나 병합 할 필요가 없다는 것을 인식하지 못했습니다. 왜냐하면 병력이 원격 기록에서 벗어나지 않았기 때문입니다. 앞으로 감을 수 있습니다. 그에 따라 내 대답을 업데이트 할 것입니다. –