繁体   English   中英

如何使用pygit2进行变基?

[英]How can I perform a rebase with pygit2?

这个问题涉及如何与pygit2合并,但是据我所知,这将导致新的提交。 有没有一种执行基准的方法,该方法不会导致新的提交,而只会将分支引用快速转发到对应于给定远程服务器的最新引用?

您可以使用Reference.set_target()快进。

实施例(快进masterorigin/master ,假定从脚本检出开始master分支在干净的状态):

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM