2.8 KiB
2.8 KiB
name, description
| name | description |
|---|---|
| github-prs | Find, inspect, and create GitHub pull requests for a branch using the GitHub CLI and git. Use when you need to locate the PR tied to a branch or open/update a PR. |
GitHub PRs (branch workflows)
This skill documents common GitHub CLI workflows for finding a PR for a branch, inspecting it, and creating one if needed.
Prerequisites
- Repository has a GitHub remote (usually
origin). - GitHub CLI (
gh) is installed and authenticated (gh auth status).
Find the PR for the current branch
# Show current branch
branch=$(git rev-parse --abbrev-ref HEAD)
# Find PR for the current branch (if one exists)
gh pr list --head "$branch" --state all
# View the PR details by branch
pr_number=$(gh pr list --head "$branch" --state all --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
gh pr view "$pr_number" --web
fi
Find PRs by branch name (explicit)
branch="feature/your-branch"
gh pr list --head "$branch" --state all
Find the PR for the current branch (alternative via git)
# If upstream is set, this is handy for branch -> PR lookup
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
if [ -n "$upstream" ]; then
gh pr list --head "${upstream#origin/}" --state all
fi
Create a PR from the current branch
branch=$(git rev-parse --abbrev-ref HEAD)
# Push branch if needed
if ! git rev-parse --symbolic-full-name "${branch}@{u}" >/dev/null 2>&1; then
git push -u origin "$branch"
fi
# Create PR (edit title/body as needed)
gh pr create \
--title "[ISSUE-123] Short summary" \
--body $'[](https://awac.attio.com/redirect/developer-preview/<preview-hash>)\n\n\n\n- Summary bullet 1\n- Summary bullet 2\n'
Update an existing PR body
pr_number=<number>
# Edit in editor
EDITOR=vim gh pr edit "$pr_number" --body-file -
# Or overwrite directly
gh pr edit "$pr_number" --body $'...'
Quick checks
# Confirm gh auth and repo
gh auth status
gh repo view --web
Troubleshooting
- If
gh pr list --headreturns nothing, the PR may not exist yet, or the branch name differs. - Use
git branch -r | rg <branch-name>to confirm the remote branch name. - Ensure you're in the correct repo (
git remote -v).