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
Notes

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
Notes

Clone a repository into a named local folder.

Create a repository interactively

Create a new repository with prompts.

bashANYrepocreate
bash
gh repo create
Notes

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
Notes

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

Fork current repository

Fork the current repository.

bashANYrepofork
bash
gh repo fork
Notes

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
Notes

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
Notes

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

View repository info

Show repository details.

bashANYrepoview
bash
gh repo view cli/cli
Notes

Show repository details.

Edit repository description

Update repository metadata.

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

Update repository metadata.

Edit repository homepage

Update the repository homepage URL.

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

Update the repository homepage URL.

Enable issues

Enable GitHub Issues for a repository.

bashANYrepoeditissues
bash
gh repo edit --enable-issues
Notes

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
Notes

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
Notes

Sync a fork with its parent repository.

Archive repository

Archive a repository.

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

Archive a repository.

Unarchive repository

Unarchive an archived repository.

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

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
Notes

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
Notes

List pull requests by state.

View a PR

Show details for a pull request.

bashANYprview
bash
gh pr view 123
Notes

Show details for a pull request.

Create a PR interactively

Create a pull request.

bashANYprcreate
bash
gh pr create
Notes

Create a pull request.

Create PR with autofill

Autofill title and body from commits.

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

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
Notes

Create a pull request non-interactively.

Check out a PR

Fetch and switch to a pull request locally.

bashANYprcheckout
bash
gh pr checkout 123
Notes

Fetch and switch to a pull request locally.

Show PR diff

Display the diff for a pull request.

bashANYprdiff
bash
gh pr diff 123
Notes

Display the diff for a pull request.

Show PR checks

Display status checks for a pull request.

bashANYprchecks
bash
gh pr checks 123
Notes

Display status checks for a pull request.

Show PR status

Show pull requests relevant to you.

bashANYprstatus
bash
gh pr status
Notes

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
Notes

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"
Notes

Close a pull request and optionally leave a comment.

Reopen a PR

Reopen a closed pull request.

bashANYprreopen
bash
gh pr reopen 123
Notes

Reopen a closed pull request.

Lock a PR conversation

Lock conversation on a pull request.

bashANYprlock
bash
gh pr lock 123 --reason resolved
Notes

Lock conversation on a pull request.

Unlock a PR conversation

Unlock a previously locked pull request.

bashANYprlock
bash
gh pr unlock 123
Notes

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
Notes

Approve a pull request.

Comment on a PR

Leave a review comment.

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

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."
Notes

Request changes during review.

Merge a PR

Merge a pull request using a merge commit.

bashANYprmerge
bash
gh pr merge 123 --merge
Notes

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
Notes

Squash merge and delete the branch.

Rebase merge a PR

Merge a pull request using rebase.

bashANYprmergerebase
bash
gh pr merge 123 --rebase
Notes

Merge a pull request using rebase.

Enable auto-merge

Enable auto-merge once checks pass.

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

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
Notes

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
Notes

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?"
Notes

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
Notes

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
Notes

Inspect mergeability and review state programmatically.

Recommended next

No recommendations yet.