| name | resolve-backport-conflicts |
| description | Resolve merge conflicts in a Mergify backport pull request. When a cherry-pick fails, Mergify commits the conflict markers as they are. This skill takes a pull request link or number as an argument. |
| disable-model-invocation | true |
How Mergify leaves the branch
Mergify backports a pull request with a cherry-pick. When the cherry-pick conflicts, Mergify runs git add on the conflicted files and commits them unresolved. The branch then holds raw conflict markers:
<<<<<<< HEAD
content of the target branch, such as version-16-hotfix
=======
content of the commit under backport
>>>>>>> <sha> (commit subject)
The HEAD side is the target branch. The >>>>>>> side is the pull request under backport. Neither side wins by default.
Steps
1. Check out the pull request
Work inside the repository that owns the pull request. If the current directory is a different repository, clone the correct one into the scratchpad directory.
gh pr view <pr-url> --json number,title,body,baseRefName,headRefName,headRepositoryOwner,url
gh pr checkout <pr-url> --force
The --force flag resets a stale local branch to the pull request head. If the working tree is dirty, stop and tell the user. Do not discard the work of the user.
2. Read the original pull request
The Mergify description holds the line This is an automatic backport of pull request #<N>. Read the number from that line. If the line is absent, read the number from the branch name .