풀 기능을 구현하기 위해 objecitive-git 및 libgit2를 사용하고 있습니다. 마찬가지로 git pull
단지 '도자기'명령이며 위로 만든다 git fetch
a로 다음에 git merge origin/master
그 내가 그것을 구현하는 방법이 될 것입니다.
fetch는 github의 fetch 브랜치에서 objective-git의 메소드를 사용하여 수행됩니다.
[remote fetchWithCredentialProvider:nil error:&error progress:nil];
아래 코드는 가져 오기 후에 수행되는 작업입니다 (성공한 것으로 알고 있음).
// Get the local branch
GTBranch *localBranch = [repo localBranchesWithError:nil][0];
// Get the remote branch
GTBranch *remoteBranch = [repo remoteBranchesWithError:nil][0];
// Get the local & remote commit
GTCommit *localCommit = [localBranch targetCommitAndReturnError:nil];
GTCommit *remoteCommit = [remoteBranch targetCommitAndReturnError:nil];
// Get the trees of both
GTTree *localTree = localCommit.tree;
GTTree *remoteTree = remoteCommit.tree;
// Get OIDs of both commits too
GTOID *localOID = localCommit.OID;
GTOID *remoteOID = remoteCommit.OID;
// Find a merge base to act as the ancestor between these two commits
GTCommit *ancestor = [repo mergeBaseBetweenFirstOID:localOID secondOID:remoteOID error:&error];
if (error) {
NSLog(@"Error finding merge base: %@", error);
}
// Get the ancestors tree
GTTree *ancestorTree = ancestor.tree;
// Merge into the local tree
GTIndex *mergedIndex = [localTree merge:remoteTree ancestor:ancestorTree error:&error];
if (error) {
NSLog(@"Error mergeing: %@", error);
}
// Write the merge to disk and store the new tree
GTTree *newTree = [mergedIndex writeTreeToRepository:repo error:&error];
if (error) {
NSLog(@"Error writing merge index to disk: %@", error);
}
애프터 mergedIndex
메모리에서 시작되는이 디스크 (에 나무로 기록 된 writeTreeToRepository
사용 git_index_write_tree_to
)을 자식 REPOS 상태에 변화가 없다. 새 트리를 HEAD로 만들거나 HEAD 또는 이와 유사한 것과 병합하는 마지막 단계가 없다고 가정하고 있지만 정확히 무엇인지 잘 모르겠습니다.
어떤 도움도 많은 의무가 있습니다.
당신은 당신이 커밋 병합에 사용할 나무가 있으면, 당신은 당신이 만들 수있는 병합 커밋 만들 필요가 createCommitWithTree
에서 GTRepository
하지만 부모님 모두 조상과 함께, 당신은 다른를 만들 것과 같은 방법. 이 기능을 사용하면 저장소가 조용한 상태 일 것으로 예상되는 경우 라이브러리에 특정 분기를 업데이트하도록 요청할 수도 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다