We support the node versions that the Node.js organization supports which as of now is Node v6 & up.
Authentication
Under the hood, we are using @octokit/rest to work with the GitHub API
The method of authentication that we use with octokit, is a personal access token
You have two options here: 1. Run gh which will start the authentication process & generate the token for you automatically - Though they are hidden, the downside of this is having to type your user & pass - Supports 2fa 2. Manually generate your personal token & add it to your ~/.gh.json
Available commands
gh help
List all comands options.
gh help --all
List specific command options.
gh help <command>
Global flags
Option
Usage
Type
--verbose
Optional
Boolean
--insane
Optional
Boolean
--no-color
Optional
Boolean
--no-hooks
Optional
Boolean
The verbose flag is useful for debugging issues.
The insane flag is a more complete verbose flag, which leaks more privacy sensitive data by default.
Shortcut for listing open pull requests for the current repository
gh pr
List open pull requests for all branches from all your repositories.
gh pr --list --all
List open pull requests for all branches in all repositories belonging to the "github" organization.
gh pr --list --all --org github
List open pull requests sent by logged user on current repository.
gh pr --list --me
List open pull requests in node-gh/gh repository.
gh pr --list --user node-gh --repo gh
List open pull requests with link and content.
gh pr --list --detailed
List open pull requests for a branch.
gh pr --list --branch master
List open pull requests and sort them by popularity (comment count).
gh pr --list --sort popularity
List open pull requests and sort them by asc long-running (old but still active).
gh pr --list --sort long-running --direction asc
List open pull requests and sort them by complexity (complexity is calculated based on number of additions, deletions, changed files, comments and review comments).
gh pr --list --date "dddd, MMMM Do YYYY, h:mm:ss a"
PR: Merge or Rebase
Option
Usage
Type
-f, --fetch
Required
Boolean
-M, --merge
Required
Boolean
-R, --rebase
Required
Boolean
-n, --number
Optional
Number
-b, --branch
Optional
String
--draft
Optional
Boolean
--remote
Optional
String
-r, --repo
Optional
String
-u, --user
Optional
String
Omitting --number will try to guess the pull number from branch name e.g. pr-1 results in --number 1. Omitting --branch will merge or rebase into config.default_branch.
Examples
Shortcut for fetching pull request and checkout into a new branch pr-1.
gh pr 1
Merge or rebase pull request into a local branch.
gh pr 1 --fetch --merge
gh pr 1 --fetch --rebase
Merge or rebase pull request into branch dev.
gh pr 1 --fetch --rebase --branch dev
gh pr 1 --fetch --merge --branch dev
PR: Comment
Option
Usage
Type
-c, --comment
Required
String
-n, --number
Required
Number
--remote
Optional
String
-r, --repo
Optional
String
-u, --user
Optional
String
Examples
Comment on a pull request.
gh pr 1 --comment "Merged, thank you!"
Submit a pull request using your default editor by passing an empty --comment
gh pr 1 --comment
PR Forward
Option
Usage
Type
--fwd
Required
String
-n, --number
Required
Number
Omitting a value for --fwd fallbacks to the default_pr_forwarder key found
in your config file.
Examples
Forward a pull request to another reviewer.
gh pr 1 --fwd username
PR: Open or Close
Option
Usage
Type
-o, --open
Required
Boolean
-C, --close
Required
Boolean
-n, --number
Required
Number
--remote
Optional
String
-r, --repo
Optional
String
-u, --user
Optional
String
Examples
Open a pull request.
gh pr 1 --open
Close a pull request.
gh pr 1 --close
Close multiple pull requests.
gh pr --close --number 1 --number 2
Open multiple pull requests.
gh pr --open --number 1 --number 2
Open or close a pull request that you've sent to someone.
gh pr 1 --close --user eduardolundgren
PR: Submit
Option
Usage
Type
-s, --submit
Required
String
-b, --branch
Optional
String
-D, --description
Optional
String
-i, --issue
Optional
Number
-r, --repo
Optional
String
-t, --title
Optional
String
Omitting a value for --submit fallbacks to the default_pr_reviewer key found
in your config file. Omitting --title will submit a pull request
using the last commit message as title.
Examples
Submit a pull request using the current branch to the repository owner or organization.
gh re --label --delete bug --user eduardolundgren --repo gh
Repo: List Labels
Option
Usage
Type
-L, --label
Required
Boolean
-l, --list
Required
Boolean
-r, --repo
Required
String
-O, --organization
Optional
String
-u, --user
Optional
String
Examples
List labels for a repository.
gh re --label --list --repo gh
List labels for a user's repository.
gh re --label --list --user eduardolundgren --repo gh
Repo: Update Label
Option
Usage
Type
-C, --color
Required
String
-L, --label
Required
Boolean
-r, --repo
Required
String
-U, --update
Required
String
-O, --organization
Optional
String
-u, --user
Optional
String
Examples
Update a label for a repository (color is a hex code with or without literal hex symbol).
gh re --label --update bug --color color --repo gh
Update a label for a user's repository.
gh re --label --update bug --color color --user eduardolundgren --repo gh
Repo: Search
Find repositories via various criteria. Repository search looks through the projects you have access to on GitHub.
You can filter the results using GitHub's search qualifiers.
Examples:
Option
Usage
Type
-s, --search
Required
Boolean
-d, --detailed
Optional
Boolean
-u, --user
Optional
String
-r, --repo
Optional
String
-O, --organization
Optional
String
-t, --type
Optional
[all, owner, public, private, member]
Examples
Search private repositories you have access to with the term "secret".
gh re --search secret --type private
OR
gh re --search secret is:private
Matches repositories from GitHub org showing detailed results.