GitHub CLI Cheatsheet
#
GitHub CLI (gh) is a command-line tool for interacting with GitHub, allowing you to manage your GitHub repositories, issues, pull requests, and more directly from your terminal. It simplifies workflows by providing a direct interface to GitHub’s features and API.
Authentication
#
Command/Option | Example | Description |
---|
gh auth login | gh auth login | Authenticate with GitHub |
gh auth logout | gh auth logout | Log out of GitHub |
gh auth status | gh auth status | View authentication status |
Repository Management
#
Command/Option | Example | Description |
---|
gh repo create | gh repo create my-repo | Create a new repository |
gh repo clone | gh repo clone owner/repo | Clone a repository |
gh repo fork | gh repo fork owner/repo | Fork a repository |
gh repo view | gh repo view owner/repo | View a repository in your browser |
gh repo list | gh repo list | List repositories |
Issues and Pull Requests
#
Command/Option | Example | Description |
---|
gh issue list | gh issue list | List issues in a repository |
gh issue view | gh issue view 123 | View an issue |
gh issue create | gh issue create | Create a new issue |
gh pr list | gh pr list | List pull requests in a repository |
gh pr view | gh pr view 123 | View a pull request |
gh pr create | gh pr create | Create a new pull request |
gh pr checkout | gh pr checkout 123 | Check out a pull request locally |
Managing Pull Requests
#
Command/Option | Example | Description |
---|
gh pr merge | gh pr merge 123 | Merge a pull request |
gh pr close | gh pr close 123 | Close a pull request |
gh pr reopen | gh pr reopen 123 | Reopen a pull request |
gh pr review | gh pr review 123 | Add a review to a pull request |
gh pr checks | gh pr checks 123 | View the status of checks for a pull request |
Managing Issues
#
Command/Option | Example | Description |
---|
gh issue close | gh issue close 123 | Close an issue |
gh issue reopen | gh issue reopen 123 | Reopen an issue |
gh issue comment | gh issue comment 123 --body "Your comment" | Comment on an issue |
Working with Gists
#
Command/Option | Example | Description |
---|
gh gist create | gh gist create myfile.txt | Create a new gist |
gh gist list | gh gist list | List your gists |
gh gist view | gh gist view 123 | View a gist |
gh gist delete | gh gist delete 123 | Delete a gist |
Notifications
#
Command/Option | Example | Description |
---|
gh notification list | gh notification list | List notifications |
gh notification mark-read | gh notification mark-read 123 | Mark a notification as read |
Configurations
#
Command/Option | Example | Description |
---|
gh config set | gh config set editor vim | Set a configuration value |
gh config get | gh config get editor | Get a configuration value |
gh config list | gh config list | List all configuration values |
This cheatsheet covers the most commonly used GitHub CLI commands and options, helping you to manage repositories, issues, pull requests, gists, notifications, and more.