2016-07-25 8 views
0

This questionpygit2でマージを実行する方法について触れ、しかし、私の理解の最高に、新しいコミットになります。新しいコミットを引き起こさないリベースを実行する方法はありますか?特定のリモートからの最新のものに対応するようにブランチ参照を単純に早送りしますか?pygit2でどのようにしてrebaseを実行できますか?

+0

、リベース。これは早送りマージです。 –

+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(「起源/支社」、GIT_BRANCH_REMOTE)](http://www.pygit2.org/references.html#pygit2.Repository.lookup_branch)実際にこのリモート(「起源」から最新の状態を取得します場合)? *編集*:値下げ – Piotrek

+0

@Piotrekいいえ、 'lookup_branch()'フェッチしません。明示的に 'fetch()'しなければなりません。更新された回答をご覧ください。 – Leon

関連する問題