Pull_Requests
Pull Requests
Propose, review, and merge code changes.
π PR Workflow
graph LR
A[Branch] --> B[Push]
B --> C[Create PR]
C --> D[Review]
D --> E[Approval]
E --> F[Merge]
F --> G[Delete Branch]
β Creating PRs
Create PR (Interactive)
gh pr create
Interactive PR creation.
Create with Title and Body
gh pr create --title "Add login feature" --body "Description here"
Creates PR with specified title and description.
Create Draft PR
gh pr create --draft
Creates draft for early feedback.
Create from Web
gh pr create --web
Opens browser to create PR.
Auto-fill from Commits
gh pr create --fill
Uses commit messages for title/body.
π View PRs
List Your PRs
gh pr list
Shows open PRs.
List All PRs
gh pr list --state all
Shows all PRs including closed.
View Specific PR
gh pr view 123
Shows details of PR #123.
View in Browser
gh pr view 123 --web
Opens PR in browser.
Check PR Status
gh pr status
Shows status of relevant PRs.
π Review PRs
Checkout PR Locally
gh pr checkout 123
Checks out PR branch locally.
View PR Diff
gh pr diff 123
Shows diff of PR changes.
Approve PR
gh pr review 123 --approve
Approves the PR.
Request Changes
gh pr review 123 --request-changes --body "Please fix X"
Requests changes before merge.
Comment on PR
gh pr review 123 --comment --body "LGTM!"
Adds comment without approval.
π Merge PRs
Merge with Merge Commit
gh pr merge 123 --merge
Creates merge commit.
Squash and Merge
gh pr merge 123 --squash
Squashes all commits into one.
Rebase and Merge
gh pr merge 123 --rebase
Rebases commits onto base.
Auto-merge When Checks Pass
gh pr merge 123 --auto --squash
Merges automatically when CI passes.
Delete Branch After Merge
gh pr merge 123 --squash --delete-branch
Merges and deletes branch.
π Update PRs
Edit PR Title
gh pr edit 123 --title "New title"
Changes PR title.
Add Reviewers
gh pr edit 123 --add-reviewer username
Adds reviewer.
Add Labels
gh pr edit 123 --add-label "bug"
Adds label.
Mark Ready for Review
gh pr ready 123
Converts draft to ready.
β Close/Reopen
Close PR
gh pr close 123
Closes without merging.
Reopen PR
gh pr reopen 123
Reopens closed PR.
π PR Template
Create .github/PULL_REQUEST_TEMPLATE.md:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
## Testing
How was this tested?
## Checklist
- [ ] Tests pass
- [ ] Docs updated
π‘ Tips
Keep PRs under 400 lines for better reviews.
Use "Fixes #123" in PR body to auto-close issues.
π Related
#git #github #pr #pullrequest #review