Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Retrieve the commit hashes for a GitHub PR and output them on a single line. Suitable for use with git cherry-pick, etc.
#!/bin/bash
$username=<your username>
$password=<your password>
$owner=<repository owner>
$repo=<repository>
$pull_request_id=<pull request id to filter by>
curl --silent -u $username:$password https://api.github.com/repos/$owner/$repo/pulls/$pull_request_id/commits \
| jq --raw-output '.[].sha' | tr '\r\n' ' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.