Cherry-pick commits across GitHub repositories using only the GitHub API
Project description
GitHub cherry-pick
Cherry-pick commits across GitHub repositories using only the GitHub API.
Uses the algorithm described by Jim's Stack Overflow
answer to perform a cherry-pick
entirely through the GitHub REST API. This is much better than doing that
through patches (e.g. patch2pr),
because git is much smarter with resolving conflicts on commits instead of
patches.
When I used patch2pr, I had to constantly rebase my patches, because on almost every update they would raise conflicts. Cherry-picking those commits works perfectly fine!
Installation
Requires Python 3.10+, I recommend using uv, but it will work fine with pip or anything else.
uv tool install ghcherry
Or run directly without installing:
uvx ghcherry --help
Usage
This tool requires a classic token with repo and workflow permissions
(workflow is needed only if commits update .github/workflows files) or
a fine-grained token with contents and workflows permissions.
If you want to cherry-pick commits in private repositories, the tool also
requires Pull requests permission for fine-grained tokens.
GITHUB_TOKEN=ghp_... ghcherry \
--target MyOrg/nixpkgs@patched \
`: # cherry-pick these commits` \
NixOS/nixpkgs/3f5ba52cc4701bf341457dfe5f6cb58e0cbb7f83 \
NixOS/nixpkgs/49ba75ed \
`: # or merge the entire branch!` \
Someone/nixpkgs@pr-branch \
`: # or even cherry-pick every commit for a pull request!` \
NixOS/nixpkgs#380691
Arguments
You can give commits, branches and or pull requests as positional arguments. Commits will be cherry-picked, while branches will be merged into the target. For pull requests, we will collect PR's commits and add it to the list of commits to cherry-pick.
Each commit/branch/PR is applied in order and builds upon the previous result.
--target/-T: Required. Target branch to which to apply cherry-picks.--first-hard-reset-to/-H: Hard reset target to this commit, before doing anything else.--pr-commits-limit: If you specify PR to cherry-pick, this is the maximum amount of commits that the pull request can have.--token/-t: GitHub token. If not specified, falls back to the$GITHUB_TOKENenvironment variable.
Supported formats:
For commits:
- Owner/RepoName/commit
- https://github.com/Owner/RepoName/commit/09588bb
For branches:
- Owner/RepoName@branch
- https://github.com/Owner/RepoName/tree/branch
For pull requests:
- Owner/RepoName#123
- https://github.com/Owner/RepoName/pull/123
Development
uv sync
uv run pre-commit install
Then commit your changes and send a pull request!
Thanks
mcstatusfor linter settings
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghcherry-1.6.0.tar.gz.
File metadata
- Download URL: ghcherry-1.6.0.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f43f3d97b5afffb05a411164e16afa150ba0b66fd393c1e903645e9e670ad123
|
|
| MD5 |
fda7d28ff9c7ddd10460a90a93441210
|
|
| BLAKE2b-256 |
5d94a0bc789195e475eb79b8e9e8678802c53cbd9eed8731e4ed1aaa11129f6a
|
Provenance
The following attestation bundles were made for ghcherry-1.6.0.tar.gz:
Publisher:
publish.yml on PerchunPak/ghcherry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghcherry-1.6.0.tar.gz -
Subject digest:
f43f3d97b5afffb05a411164e16afa150ba0b66fd393c1e903645e9e670ad123 - Sigstore transparency entry: 1554958812
- Sigstore integration time:
-
Permalink:
PerchunPak/ghcherry@457cf237bc8e070506a02e30e8a994a001be6c65 -
Branch / Tag:
refs/tags/v1.6.0 - Owner: https://github.com/PerchunPak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@457cf237bc8e070506a02e30e8a994a001be6c65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ghcherry-1.6.0-py3-none-any.whl.
File metadata
- Download URL: ghcherry-1.6.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5337179a636bc476c9189d03eab7546f0e4415bcc989e31c95ff1961d654a78f
|
|
| MD5 |
9714ca58e1de395b06dfeca6b5cf33b6
|
|
| BLAKE2b-256 |
143fc12cf5d71d4a5bb54a489e7721ea8aef7fd7354fb4769b7fee9699a2bdae
|
Provenance
The following attestation bundles were made for ghcherry-1.6.0-py3-none-any.whl:
Publisher:
publish.yml on PerchunPak/ghcherry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghcherry-1.6.0-py3-none-any.whl -
Subject digest:
5337179a636bc476c9189d03eab7546f0e4415bcc989e31c95ff1961d654a78f - Sigstore transparency entry: 1554958891
- Sigstore integration time:
-
Permalink:
PerchunPak/ghcherry@457cf237bc8e070506a02e30e8a994a001be6c65 -
Branch / Tag:
refs/tags/v1.6.0 - Owner: https://github.com/PerchunPak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@457cf237bc8e070506a02e30e8a994a001be6c65 -
Trigger Event:
push
-
Statement type: