Skip to content

Instantly share code, notes, and snippets.

@tklauser
Last active November 7, 2025 08:44
Show Gist options
  • Select an option

  • Save tklauser/9b0c1897bfaf16bd18bd956b6fd1f18e to your computer and use it in GitHub Desktop.

Select an option

Save tklauser/9b0c1897bfaf16bd18bd956b6fd1f18e to your computer and use it in GitHub Desktop.
Find out which PR introduced a commit
#!/usr/bin/env bash
set -o errexit
set -o nounset
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 <SHA>"
fi
SHA=$1
# see gh pr list --help for JSON fields and gh help formatting for template formatting options
gh pr list --search ${SHA} --state merged --json title,url,mergedAt --template \
'{{range .}}{{.url}} {{.title | autocolor "green"}} (merged {{(timeago .mergedAt)}}){{"\n"}}{{end}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment