TL;DR: A cheat sheet of gh (GitHub CLI) commands for repos, issues, PRs, and
workflows.
GitHub CLI Shortcuts#
A short guide to the most useful GitHub CLI commands for managing repositories, issues, pull requests, and workflows.
// TODO(ai_gp): Convert into a table
auth: Authenticate gh and git with GitHub
browse: Open repositories, issues, pull requests, and more in the browser
issue: Manage issues
pr: Manage pull requests
project: Work with GitHub Projects.
repo: Manage repositories
run: View details about workflow runs
workflow: View details about GitHub Actions workflows
gh referenceto show a full reference of all the commands- E.g.,
gh reference | vim -
Subcommands#
Authentication & Setup#
- Check authentication status
Repository Management#
-
View repository details
-
List your repositories
Issues#
-
List issues
-
View a specific issue
-
Create a new issue
-
Add a comment to an issue
-
Close an issue
Pull Requests#
-
List pull requests
-
View a PR
-
Create a new PR
-
Check PR status
-
Merge a PR
Workflows & Actions#
-
List GitHub Actions workflows
-
List workflow runs
-
View a specific run
-
Watch a run in progress
Useful Flags & Options#
| Flag | Description |
|---|---|
-R, --repo <owner/repo> |
Specify repository (useful when not in a repo directory) |
--json |
Format output as JSON |
--limit <number> |
Limit the number of results |
-a, --assignee <user> |
Filter by assignee |
-L, --label <label> |
Filter by label |
-s, --state <state> |
Filter by state (open, closed, merged) |
--author <user> |
Filter by author |
--head <branch> |
Filter by head branch |
--base <branch> |
Filter by base branch |
Working with Multiple Repositories#
-
List issues from a different repo
-
Check PRs across repos
Useful One-Liners#
-
List all open PRs with JSON output
-
Create an issue with a label
-
List PRs assigned to you
Common Workflows#
-
Finding current GitHub issue from the branch
-
Finding current GitHub PR
-
Creating a Pull Request
> git checkout -b feature/my-feature Switched to a new branch 'feature/my-feature' > git add . && git commit -m "Add my feature" && git push origin feature/my-feature [feature/my-feature abc1234] Add my feature > gh pr create --title "Add my feature" --body "Description of changes" Creating pull request for feature/my-feature into main #39 (https://github.com/gpsaggese/umd_classes2/pull/39) -
Managing Issues
> gh issue create --title "Bug: crashes on logout" --body "App crashes when user logs out" --label "bug,urgent" Creating issue in gpsaggese/umd_classes2 #45 (https://github.com/gpsaggese/umd_classes2/issues/45) > gh issue comment 45 --body "I'm working on this" Commenting on issue #45 in gpsaggese/umd_classes2 https://github.com/gpsaggese/umd_classes2/issues/45#issuecomment-1234567 > gh issue close 45 Closed issue #45 in gpsaggese/umd_classes2