Cherry-Picking PRs into Release Branches
This document describes how to cherry-pick a merged pull request into a release branch for patch releases.
Prerequisites
- gh CLI installed and authenticated
- Clean git working tree
Overview
When a bug fix or change needs to be included in an existing release (e.g. v0.1.1), the corresponding PR that was merged into main can be cherry-picked into the appropriate release branch (e.g. release-v0.1).
Using the cherry-pick script
A convenience script is provided at hack/cherry-pick.sh. It automates the entire process: creating a branch, cherry-picking the merge commit, pushing, and opening a PR against the release branch.
./hack/cherry-pick.sh <PR-number> <release-branch>Example
Cherry-pick PR #123 into the release-v0.1 branch:
./hack/cherry-pick.sh 123 release-v0.1This will:
- Fetch the merge commit of PR #123 from GitHub
- Create a new branch
cherry-pick-123-into-release-v0.1fromorigin/release-v0.1 - Cherry-pick the merge commit
- Push the branch and open a PR targeting
release-v0.1
Handling conflicts
If the cherry-pick results in merge conflicts, the script will stop and print instructions. To resolve:
Fix the conflicting files
Stage the resolved files with
git addContinue the cherry-pick:
shellgit cherry-pick --continuePush and create the PR manually:
shellgit push origin cherry-pick-<PR>-into-<release-branch> gh pr create --base <release-branch> --title "🍒 [<release-branch>] <title>" --body "Cherry-pick of #<PR> into <release-branch>."
Release notes
The release-drafter workflow automatically drafts release notes for release branches. Once the cherry-pick PR is merged into the release branch, it will be included in the next draft release for that branch.