my-notes

Pull_Requests

1 min read

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

Small PRs

Keep PRs under 400 lines for better reviews.

Link Issues

Use "Fixes #123" in PR body to auto-close issues.



#git #github #pr #pullrequest #review

Built with mdgarden