2016-07-25 5 views
0

This questionpygit2과 병합을 수행하는 방법을 다루지 만, 내 이해를 돕기 위해 새로운 커밋이 발생합니다. 새로운 커밋을 초래하지 않을 리베이스를 수행 할 수있는 방법이 있으며 브랜치 참조를 주어진 리모트의 최신 버전과 일치하도록 간단하게 빨리 감기 할 것입니까?pygit2로 rebase를 수행하려면 어떻게해야합니까?

+0

하는 REBASE. 그것은 빠른 전진 병합입니다. –

+0

@WayneWerner 네, 맞습니다. 나는'pygit2'를 가지고 놀아서 현재 브랜치의 변경 사항을 리모트의 같은 브랜치의 최신 상태의 맨 위에 * 적용해야 할 것이다. – Piotrek

답변

1

Reference.set_target()으로 빨리 감기 할 수 있습니다.

예 (스크립트가 깨끗한 상태로 체크 아웃 master 지점에서 시작한다고 가정 origin/mastermaster을 빨리 감기) :

, 엄밀히 말하면 아니에요
repo.remotes['origin'].fetch() 
origin_master = repo.lookup_branch('origin/master', pygit2.GIT_BRANCH_REMOTE) 
master = repo.lookup_branch('master') 
master.set_target(origin_master.target) 

# Fast-forwarding with set_target() leaves the index and the working tree 
# in their old state. That's why we need to checkout() and reset() 
repo.checkout('refs/heads/master') 
repo.reset(master.target, pygit2.GIT_RESET_HARD) 
+0

[repo.lookup_branch ('origin/branch1', GIT_BRANCH_REMOTE)] (http://www.pygit2.org/references.html#pygit2.Repository.lookup_branch)이 실제로 원격에서 '최신 상태'를 가져옵니다. 케이스)? * edit * : markdown – Piotrek

+0

@Piotrek 아니요, 'lookup_branch()'가 가져 오지 않습니다. 명시 적으로'fetch()'해야합니다. 업데이트 된 답변보기 – Leon