gpt4 book ai didi

python - Pygit2 - merge 没有快进的分支

转载 作者:行者123 更新时间:2023-11-30 23:19:02 25 4
gpt4 key购买 nike

我本质上是在尝试执行“git merge --no-ff 分支”来将我的分支 merge 回来。查看 Pygit2 文档,我不太确定执行此操作的正确方法是什么。直接的想法是做这样的事情:

repo.merge(branch.target)

但是,我没有看到任何与无快进 merge 的选项。有没有人广泛使用 pygit2 可以给我任何见解?非常感谢所有的帮助。

最佳答案

However, I do not see any options for merging with no-fastforward.

那是因为,从 pygit2 merge documentation :

it only does the merge, does not commit nor update the branch reference in the case of a fastforward.

这意味着一旦 merge 本身完成,您就可以决定创建一个新的提交。

You can now inspect the index file for conflicts and get back to the user to resolve if there are.
Once there are no conflicts left, you can create a commit with these two parents.

other_branch_tip = '5ebeeebb320790caf276b9fc8b24546d63316533'
repo.merge(other_branch_tip)

user = repo.default_signature()
tree = repo.index.write_tree()
new_commit = repo.create_commit('HEAD', user, user, tree,
[repo.head.target, other_branch_tip])

关于python - Pygit2 - merge 没有快进的分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26310299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com