Shortcut for listing open pull requests for the current repository.
gh pr
Get information about a pull request.
gh pr --info number
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 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 --sort complexity
3. Fetch
Option
Usage
Type
-f, --fetch
Required
Boolean
-n, --number
Required
Number
-M, --merge
Optional
Boolean
-R, --rebase
Optional
Boolean
--remote
Optional
String
-r, --repo
Optional
String
-u, --user
Optional
String
Examples
Shortcut for fetching pull request and checkout into a new branch pr-1.
gh pr 1
Fech pull request rebasing or merging into the current branch.
gh pr 1 --fetch --rebase
gh pr 1 --fetch --merge
4. Merge or rebase
Option
Usage
Type
-M, --merge
Required
Boolean
-R, --rebase
Required
Boolean
-n, --number
Optional
Number
-b, --branch
Optional
String
--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
Merge or rebase pull request into a 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
5. 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!"
6. 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
7. 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
8. 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.
Shortcut for opening the GitHub repository page in the browser.
gh re
Open GitHub repository page in the browser.
gh re --browser --user eduardolundgren --repo node-gh
2. List
Option
Usage
Type
-l, --list
Required
Boolean
-d, --detailed
Optional
Boolean
-u, --user
Optional
String
-t, --type
Optional
[all, owner, public, private, member]
Examples
List all repositories.
gh re --list
List all private repositories.
gh re --list --type private
List all repositories from someone.
gh re --list --user zenorocha
3. Create
Option
Usage
Type
-N, --new
Required
String
-O, --organization
Optional
String
-c, --clone
Optional
Boolean
-t, --type
Optional
[private]
--init
Optional
Boolean
--gitignore
Optional
String
--homepage
Optional
String
--description
Optional
String
Examples
Create a new GitHub repository and clone on the current directory.
gh re --new foo --clone
Create a new GitHub repository for an organization.
gh re --new foo --organization node-gh
Create a new GitHub repository using .gitignore template for Ruby.
gh re --new gemified --gitignore Ruby
Create a new private repository on GitHub, initializing it with a initial commit of the README.
gh re --new foo --init --type private
4. Fork
Option
Usage
Type
-f, --fork
Required
String
-u, --user
Required
String
-O, --organization
Optional
String
Examples
Fork a GitHub repository.
gh re --fork repo --user user
Fork a GitHub repository into the node-gh organization.
gh re --fork repo --user user --organization node-gh
5. Delete
Option
Usage
Type
-D, --delete
Required
String
-u, --user
Required
String
Example
Delete a repository of the logged user.
gh re --delete foo
6. Clone
Option
Usage
Type
-c, --clone
Required
String
-r, --repo
Required
String
-O, --organization
Optional
String
-P, --protocol
Optional
String
-u, --user
Optional
String
Examples
Clone a repository.
gh re --clone --repo gh
Clone a repository from a specific user using HTTPS protocol.
gh re --clone --user eduardolundgren --repo gh --protocol https
7. Create Label
Option
Usage
Type
-C, --color
Required
String
-L, --label
Required
Boolean
-N, --new
Required
String
-r, --repo
Required
String
-O, --organization
Optional
String
-u, --user
Optional
String
Examples
Create a label for a repository.
gh re --label --new bug --color color --repo gh
Create a label for a user's repository.
gh re --label --new bug --color color --user eduardolundgren --repo gh
8. Delete Label
Option
Usage
Type
-L, --label
Required
Boolean
-D, --delete
Required
String
-r, --repo
Required
String
-O, --organization
Optional
String
-u, --user
Optional
String
Examples
Delete a label from a repository.
gh re --label --delete bug --repo gh
Delete a label from a user's repository.
gh re --label --delete bug --user eduardolundgren --repo gh
9. 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
10. 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.
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
Gists
gh gists
Alias:gh gi
1. Open in Browser
Option
Usage
Type
-B, --browser
Required
Boolean
-u, --user
Optional
String
-i, --id
Optional
String
Examples
Shortcut for opening your Gists in the browser.
gh gi
Open a Gist in the browser.
gh gi --browser --id 5991877
2. List
Option
Usage
Type
-l, --list
Required
Boolean
-u, --user
Optional
String
Examples
List all gists.
gh gi --list
List all gists from someone.
gh gi --list --user brunocoelho
3. Create
Option
Usage
Type
-N, --new
Required
String
-c, --content
Optional
String
-d, --description
Optional
String
-p, --private
Optional
Boolean
Examples
Create a Gist hello containing "Hello World".
gh gi --new hello --content "Hello World!"
Create a private Gist hello containing "Hello World".
gh gi --new hello --content "Hello World!" --private
4. Fork
Option
Usage
Type
-f, --fork
Required
String
Examples
Fork a Gist.
gh gi --fork 5444883
5. Delete
Option
Usage
Type
-D, --delete
Required
String
Example
Delete a Gist.
gh gi --delete 4252323
Delete multiple Gists.
gh gi --delete 4252321 --delete 4252322
User
gh user
Alias:gh us
1. Login/Logout
Option
Usage
Type
-l, --login
Required
Boolean
-L, --logout
Required
Boolean
Examples
Login or show current logged in GitHub user.
gh user --login
Logout current GitHub account.
gh user --logout
2. Whoami
Option
Usage
Type
-w, --whoami
Required
Boolean
Examples
Prints your username to stdout.
gh user --whoami
Alias
gh alias
Alias:gh al
1. List
Option
Usage
Type
-l, --list
Required
Boolean
Examples
Shortcut for listing aliases.
gh alias
List aliases.
gh alias --list
2. Add
Option
Usage
Type
-a, --add
Required
String
-u, --user
Required
String
Examples
Create alias for username.
gh alias --add zeno --user zenorocha
3. Remove
Option
Usage
Type
-r, --remove
Required
String
Examples
Remove alias.
gh alias --remove zeno
Config
There are some pretty useful configurations that you can set on .gh.json.
This file can be found under home directory (on MacOSx: /Users/yourName/.gh.json on Windows: C:\\Users\yourName\.gh.json).
You can also set per-project configurations by adding a .gh.json file in your project's root folder and overriding existing keys.
GitHub API configurations. Change it if you're a GitHub Enterprise user.