Skip to content

Instantly share code, notes, and snippets.

@settermjd
Created November 28, 2017 15:56
Show Gist options
  • Save settermjd/5585b898ce4c795c35d5d0e2b563adf3 to your computer and use it in GitHub Desktop.
Save settermjd/5585b898ce4c795c35d5d0e2b563adf3 to your computer and use it in GitHub Desktop.
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