Skip to content Skip to sidebar Skip to footer

How To Make A Git Merge By Pygit2

I try to merge branch into master: repo = pygit2.Repository('/path/to/repo/') branch = repo.lookup_branch('upstream/branch', pygit2.GIT_BRANCH_REMOTE) oid = branch.target merge_res

Solution 1:

The merge function does the merge (or in this case tells you you could skip it), but it's up to you (or the user of the tool) whether you want to move the current branch to the new position.

Doing that is the same as any other time you want to change a reference. In this case you want to get to the current branch, which you do via resolving HEAD to a non-symbolic reference and setting its target.

repo.lookup_reference('HEAD').resolve().target = merge_result.fastforward_oid

Post a Comment for "How To Make A Git Merge By Pygit2"