Work seamlessly with GitHub from the command line.
# ---------------------------------------------------
# Work seamlessly with GitHub from the command line
# ---------------------------------------------------
# To clone a repository locally:
gh repo clone <owner>/<repository>
# To create a new issue:
gh issue create
# To view and filter a repository's open issues:
gh issue list
# To view an issue in the browser:
gh issue view --web <issue_number>
# To create a pull request:
gh pr create
# To view a pull request in the browser:
gh pr view --web <pr_number>
# To check out pull requests locally:
gh pr checkout <pr_number>
# To check the status of a repository's pull requests:
gh pr status
# ---------------------------------------------------
# Change configuration for GitHub cli.
# ---------------------------------------------------
# To display what Git protocol is being used:
gh config get git_protocol
# To set protocol to SSH:
gh config set git_protocol <ssh>
# To set text editor to Vim:
gh config set editor <vim>
# To reset to default text editor:
gh config set editor <"">
# To disable interactive prompts:
gh config set prompt <disabled>
# To set a specific configuration value:
gh config set <key> <value>
# ---------------------------------------------------
# Manage GitHub releases from the command line.
# ---------------------------------------------------
# To list releases in a GitHub repository, limited to 30 items:
gh release list
# To display information about a specific release:
gh release view <tag>
# To create a new release:
gh release create <tag>
# To delete a specific release:
gh release delete <tag>
# To download assets from a specific release:
gh release download <tag>
# To upload assets to a specific release:
gh release upload <tag> <path/to/file1> <path/to/file2>
# ---------------------------------------------------
# Authenticate with a GitHub host from the command line.
# ---------------------------------------------------
# To login with interactive prompt:
gh auth login
# To login with a token from standard input (created in https://github.com/settings/tokens):
echo <your_token> | gh auth login --with-token
# To check if you are logged in:
gh auth status
# To log out:
gh auth logout
# To login with a specific GitHub Enterprise Server:
gh auth login --hostname <github.example.com>
# ---------------------------------------------------
# Manage GitHub pull requests from the command line.
# ---------------------------------------------------
# To create a pull request:
gh pr create
# To check out a pull request locally:
gh pr checkout <pr_number>
# To view the changes made in the PR:
gh pr diff
# To approve the pull request of the current branch:
gh pr review --approve
# To merge the pull request associated with the current branch, removing the branch on both the local and the remote:
gh pr merge
# ---------------------------------------------------
# Work with GitHub repositories on the command line.
# ---------------------------------------------------
# To create a new repository (if the repository name is not set, the default name will be the name of the current directory):
gh repo create <name>
# To clone a repository:
gh repo clone <owner>/<repository>
# To fork and clone a repository:
gh repo fork <owner>/<repository> --clone
# To view a repository in the web browser:
gh repo view <repository> --web