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

Create, clone, fork, sync, and inspect repositories.

Clone a repository

Clone a repository using OWNER/REPO syntax.

bashANYrepoclone
bash
gh repo clone cli/cli

Clone a repository using OWNER/REPO syntax.

Clone into a specific directory

Clone a repository into a named local folder.

bashANYrepoclone
bash
gh repo clone cli/cli my-cli-copy

Clone a repository into a named local folder.

Create a repository interactively

Create a new repository with prompts.

bashANYrepocreate
bash
gh repo create

Create a new repository with prompts.

Create a public repo from current directory

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

bashANYrepocreatepush
bash
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

Fork the current repository.

bashANYrepofork
bash
gh repo fork

Fork the current repository.

Fork and clone a repo

Fork a repo and clone your fork locally.

bashANYrepoforkclone
bash
gh repo fork cli/cli --clone

Fork a repo and clone your fork locally.

Set default repo context

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

bashANYrepocontext
bash
gh repo set-default my-org/platform-api

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

View repository info

Show repository details.

bashANYrepoview
bash
gh repo view cli/cli

Show repository details.

Edit repository description

Update repository metadata.

bashANYrepoedit
bash
gh repo edit --description "Internal platform tooling"

Update repository metadata.

Edit repository homepage

Update the repository homepage URL.

bashANYrepoedit
bash
gh repo edit --homepage "https://docs.example.com"

Update the repository homepage URL.

Enable issues

Enable GitHub Issues for a repository.

bashANYrepoeditissues
bash
gh repo edit --enable-issues

Enable GitHub Issues for a repository.

Delete a repository

Delete a repository without interactive confirmation.

bashANYrepodelete
bash
gh repo delete my-org/old-repo --yes

Delete a repository without interactive confirmation.

Sync fork from upstream

Sync a fork with its parent repository.

bashANYreposyncfork
bash
gh repo sync my-fork/repo

Sync a fork with its parent repository.

Archive repository

Archive a repository.

bashANYrepoarchive
bash
gh repo archive my-org/legacy-repo --yes

Archive a repository.

Unarchive repository

Unarchive an archived repository.

bashANYrepoarchive
bash
gh repo unarchive my-org/legacy-repo

Unarchive an archived repository.

Pull Requests Core

Create, inspect, and manage pull requests.

List pull requests

List open pull requests for the current repo.

bashANYprlist
bash
gh pr list

List open pull requests for the current repo.

List closed PRs

List pull requests by state.

bashANYprlist
bash
gh pr list --state closed --limit 100

List pull requests by state.

View a PR

Show details for a pull request.

bashANYprview
bash
gh pr view 123

Show details for a pull request.

Create a PR interactively

Create a pull request.

bashANYprcreate
bash
gh pr create

Create a pull request.

Create PR with autofill

Autofill title and body from commits.

bashANYprcreate
bash
gh pr create --fill --base main

Autofill title and body from commits.

Create PR with explicit title/body

Create a pull request non-interactively.

bashANYprcreate
bash
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

Fetch and switch to a pull request locally.

bashANYprcheckout
bash
gh pr checkout 123

Fetch and switch to a pull request locally.

Show PR diff

Display the diff for a pull request.

bashANYprdiff
bash
gh pr diff 123

Display the diff for a pull request.

Show PR checks

Display status checks for a pull request.

bashANYprchecks
bash
gh pr checks 123

Display status checks for a pull request.

Show PR status

Show pull requests relevant to you.

bashANYprstatus
bash
gh pr status

Show pull requests relevant to you.

Mark draft PR ready

Mark a draft pull request as ready for review.

bashANYprdraft
bash
gh pr ready 123

Mark a draft pull request as ready for review.

Close a PR

Close a pull request and optionally leave a comment.

bashANYprclose
bash
gh pr close 123 --comment "Superseded by #456"

Close a pull request and optionally leave a comment.

Reopen a PR

Reopen a closed pull request.

bashANYprreopen
bash
gh pr reopen 123

Reopen a closed pull request.

Lock a PR conversation

Lock conversation on a pull request.

bashANYprlock
bash
gh pr lock 123 --reason resolved

Lock conversation on a pull request.

Unlock a PR conversation

Unlock a previously locked pull request.

bashANYprlock
bash
gh pr unlock 123

Unlock a previously locked pull request.

Reviews and Merge

Review, comment, merge, and inspect mergeability.

Approve a PR

Approve a pull request.

bashANYprreviewapprove
bash
gh pr review 123 --approve

Approve a pull request.

Comment on a PR

Leave a review comment.

bashANYprreviewcomment
bash
gh pr review 123 --comment --body "Looks good overall."

Leave a review comment.

Request changes on a PR

Request changes during review.

bashANYprreviewchanges
bash
gh pr review 123 --request-changes --body "Please add tests."

Request changes during review.

Merge a PR

Merge a pull request using a merge commit.

bashANYprmerge
bash
gh pr merge 123 --merge

Merge a pull request using a merge commit.

Squash merge a PR

Squash merge and delete the branch.

bashANYprmergesquash
bash
gh pr merge 123 --squash --delete-branch

Squash merge and delete the branch.

Rebase merge a PR

Merge a pull request using rebase.

bashANYprmergerebase
bash
gh pr merge 123 --rebase

Merge a pull request using rebase.

Enable auto-merge

Enable auto-merge once checks pass.

bashANYprmergeauto
bash
gh pr merge 123 --auto --squash

Enable auto-merge once checks pass.

Use admin merge

Merge bypassing branch protections if you have admin privileges.

bashANYprmergeadmin
bash
gh pr merge 123 --admin --merge

Merge bypassing branch protections if you have admin privileges.

Update branch from base

Update a PR branch with the latest base branch changes.

bashANYprupdate-branch
bash
gh pr update-branch 123 --rebase

Update a PR branch with the latest base branch changes.

Leave PR comment

Add a general pull request comment.

bashANYprcomment
bash
gh pr comment 123 --body "Can you clarify the migration path?"

Add a general pull request comment.

Edit PR metadata

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

bashANYpredit
bash
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

Inspect mergeability and review state programmatically.

bashANYprjson
bash
gh pr view 123 --json mergeStateStatus,isDraft,reviewDecision

Inspect mergeability and review state programmatically.

Recommended next

No recommendations yet.