GitHub CLI Repos and Pull Requests

Repository creation, forking, syncing, pull request creation, review, and merge workflows in GitHub CLI.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Repository Basics
Clone a repository
gh repo clone cli/cli

# Clone a repository using OWNER/REPO syntax.

Clone into a specific directory
gh repo clone cli/cli my-cli-copy

# Clone a repository into a named local folder.

Create a repository interactively
gh repo create

# Create a new repository with prompts.

Create a public repo from current directory
gh repo create my-new-repo --public --source=. --remote=origin --push

# Create a repository from the current directory and push initial contents.

Fork current repository
gh repo fork

# Fork the current repository.

Fork and clone a repo
gh repo fork cli/cli --clone

# Fork a repo and clone your fork locally.

Set default repo context
gh repo set-default my-org/platform-api

# Set the default repository for future gh commands in this directory.

View repository info
gh repo view cli/cli

# Show repository details.

Edit repository description
gh repo edit --description "Internal platform tooling"

# Update repository metadata.

Edit repository homepage
gh repo edit --homepage "https://docs.example.com"

# Update the repository homepage URL.

Enable issues
gh repo edit --enable-issues

# Enable GitHub Issues for a repository.

Delete a repository
gh repo delete my-org/old-repo --yes

# Delete a repository without interactive confirmation.

Sync fork from upstream
gh repo sync my-fork/repo

# Sync a fork with its parent repository.

Archive repository
gh repo archive my-org/legacy-repo --yes

# Archive a repository.

Unarchive repository
gh repo unarchive my-org/legacy-repo

# Unarchive an archived repository.

## Pull Requests Core
List pull requests
gh pr list

# List open pull requests for the current repo.

List closed PRs
gh pr list --state closed --limit 100

# List pull requests by state.

View a PR
gh pr view 123

# Show details for a pull request.

Create a PR interactively
gh pr create

# Create a pull request.

Create PR with autofill
gh pr create --fill --base main

# Autofill title and body from commits.

Create PR with explicit title/body
gh pr create --title "Add health endpoint" --body "Adds /healthz" --base main --head feature/health

# Create a pull request non-interactively.

Check out a PR
gh pr checkout 123

# Fetch and switch to a pull request locally.

Show PR diff
gh pr diff 123

# Display the diff for a pull request.

Show PR checks
gh pr checks 123

# Display status checks for a pull request.

Show PR status
gh pr status

# Show pull requests relevant to you.

Mark draft PR ready
gh pr ready 123

# Mark a draft pull request as ready for review.

Close a PR
gh pr close 123 --comment "Superseded by #456"

# Close a pull request and optionally leave a comment.

Reopen a PR
gh pr reopen 123

# Reopen a closed pull request.

Lock a PR conversation
gh pr lock 123 --reason resolved

# Lock conversation on a pull request.

Unlock a PR conversation
gh pr unlock 123

# Unlock a previously locked pull request.

## Reviews and Merge
Approve a PR
gh pr review 123 --approve

# Approve a pull request.

Comment on a PR
gh pr review 123 --comment --body "Looks good overall."

# Leave a review comment.

Request changes on a PR
gh pr review 123 --request-changes --body "Please add tests."

# Request changes during review.

Merge a PR
gh pr merge 123 --merge

# Merge a pull request using a merge commit.

Squash merge a PR
gh pr merge 123 --squash --delete-branch

# Squash merge and delete the branch.

Rebase merge a PR
gh pr merge 123 --rebase

# Merge a pull request using rebase.

Enable auto-merge
gh pr merge 123 --auto --squash

# Enable auto-merge once checks pass.

Use admin merge
gh pr merge 123 --admin --merge

# Merge bypassing branch protections if you have admin privileges.

Update branch from base
gh pr update-branch 123 --rebase

# Update a PR branch with the latest base branch changes.

Leave PR comment
gh pr comment 123 --body "Can you clarify the migration path?"

# Add a general pull request comment.

Edit PR metadata
gh pr edit 123 --add-label backend --add-reviewer team/backend

# Update title, body, labels, reviewers, or assignees on a PR.

Inspect mergeability via JSON
gh pr view 123 --json mergeStateStatus,isDraft,reviewDecision

# Inspect mergeability and review state programmatically.

Recommended next

No recommendations yet.