Node GH
All the power of GitHub in your terminal.
Table of contents
Install
[sudo] npm install -g gh
Usage
gh [command] [payload] [--flags]
Dependencies
In order to sucessfully run this project you must have NodeJS >= v0.12.0 installed.
Demonstration
Available commands
gh help
gh help --all
```
gh help
```
Global flags
Option | Usage | Type |
---|
--verbose | Optional | Boolean |
--insane | 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.
Pull requests
gh pull-request
Alias: gh pr
1. Info
Option | Usage | Type |
---|
-u , --user | Required | String |
-I , --info | Required | Boolean |
-n , --number | Required | String |
-r , --repo | Optional | String |
-u , --user | Optional | String |
2. List
Option | Usage | Type |
---|
-l , --list | Required | Boolean |
-a , --all | Optional | Boolean |
-O , --org | Optional | String |
-m , --me | Optional | Boolean |
-d , --detailed | Optional | Boolean |
--direction | Optional | [asc , desc ] |
-b , --branch | Optional | String |
--remote | Optional | String |
-r , --repo | Optional | String |
--sort | Optional | [created , updated , popularity , long-running , complexity ] |
-S , --state | Optional | [open , closed ] |
-u , --user | Optional | String |
Examples
gh pr
```
gh pr --info number
```
gh pr --list --all
```
gh pr --list --all --org github
```
gh pr --list --me
```
gh pr --list --detailed
```
gh pr --list --branch master
```
gh pr --list --sort popularity
```
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
gh pr 1
```
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
gh pr 1 --fetch --merge
```
```
gh pr 1 --fetch --rebase
```
gh pr 1 --fetch --rebase --branch dev
```
```
gh pr 1 --fetch --merge --branch dev
```
Option | Usage | Type |
---|
-c , --comment | Required | String |
-n , --number | Required | Number |
--remote | Optional | String |
-r , --repo | Optional | String |
-u , --user | Optional | String |
Examples
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
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
gh pr 1 --open
```
gh pr 1 --close
```
gh pr --close --number 1 --number 2
```
gh pr --open --number 1 --number 2
```
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.
Examples
gh pr --submit eduardolundgren --title 'Fix #32' --description 'Awesome fix'
```
gh pr --submit eduardolundgren --branch dev
```
gh pr --submit eduardolundgren --issue 150
```
9. Open in Browser
Option | Usage | Type |
---|
-B , --browser | Required | Boolean |
-n , --number | Required | Number |
-u , --user | Optional | String |
-r , --repo | Optional | String |
Examples
gh pr 100 --browser
```
Notifications
gh notification
Alias: gh nt
1. Latest
Option | Usage | Type |
---|
-l , --latest | Required | Boolean |
--remote | Optional | String |
-r , --repo | Optional | String |
-u , --user | Optional | String |
Examples
gh nt
```
gh nt --latest --user eduardolundgren --repo node-gh
```
2. Watch
Option | Usage | Type |
---|
-w , --watch | Required | Boolean |
--remote | Optional | String |
-r , --repo | Optional | String |
-u , --user | Optional | String |
Examples
gh nt --watch
```
gh nt --watch --user eduardolundgren --repo node-gh
```
Issues
gh issue
Alias: gh is
1. Create
Option | Usage | Type |
---|
-N , --new | Required | Boolean |
-t , --title | Required | String |
-A , --assignee | Optional | String |
-L , --label | Optional | String |
-m , --message | Optional | String |
--remote | Optional | String |
-r , --repo | Optional | String |
-u , --user | Optional | String |
Examples
gh is 'Node GH rocks!' 'Body with Markdown support'
```
gh is --new --title 'Node GH rocks!' --message 'Body with Markdown support' --user eduardolundgren --repo node-gh
```
gh is --new --title 'Node GH rocks!' --label bug,question,test
```
gh is --new --title 'Node GH rocks!' --assignee zenorocha
```
Option | Usage | Type |
---|
-c , --comment | Required | String |
-n , --number | Required | Number |
--remote | Optional | String |
-r , --repo | Optional | String |
-u , --user | Optional | String |
Examples
gh is 1 --comment 'Node GH rocks!'
```
gh is 1 --comment 'Node GH rocks!' --user eduardolundgren --repo node-gh
```
3. 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
gh is 1 --open
```
gh is 1 --close
```
gh is --close --number 1 --number 2
```
gh is --open --number 1 --number 2
```
gh is 1 --close --user eduardolundgren
```
4. List
Option | Usage | Type |
---|
-l , --list | Required | Boolean |
-a , --all | Optional | Boolean |
-A , --assignee | Optional | String |
-d , --detailed | Optional | Boolean |
-L , --label | Optional | String |
-M , --milestone | Optional | [Number , String ] |
--remote | Optional | String |
-r , --repo | Optional | String |
-S , --state | Optional | [open , closed ] |
-u , --user | Optional | String |
Examples
gh is
```
gh is --list --all
```
gh is --list --assignee zenorocha
```
gh is --list --detailed
```
gh is --list --state closed
```
gh is --list --milestone 1
```
gh is --list --label todo,bug
```
gh is --list --user eduardolundgren --repo node-gh
```
5. Open in Browser
Option | Usage | Type |
---|
-B , --browser | Required | Boolean |
-n , --number | Required | Number |
-u , --user | Optional | String |
-r , --repo | Optional | String |
Examples
- Shortcut for opening GitHub issue page in the browser.
gh is 100
```
gh is 100 --browser
```
6. Search
Option | Usage | Type |
---|
-s , --search | Required | Boolean |
-a , --all | Optional | Boolean |
-d , --detailed | Optional | Boolean |
-r , --repo | Optional | String |
-u , --user | Optional | String |
Examples
gh is --search 'term'
```
gh is --all --user node-gh --search 'term'
```
gh is --user node-gh --repo gh --search 'term'
```
gh is --user node-gh --repo gh --search 'term'
```
gh is --user node-gh --repo gh --search 'updated:<=2013-05-24'
```
Repo
gh repo
Alias: gh re
1. Open in Browser
Option | Usage | Type |
---|
-B , --browser | Required | Boolean |
-u , --user | Optional | String |
-r , --repo | Optional | String |
Examples
gh re
```
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
gh re --list
```
gh re --list --type private
```
gh re --list --user zenorocha
```
3. Create
Option | Usage | Type |
---|
-N , --new | Required | String |
--organization | Optional | String |
-c , --clone | Optional | Boolean |
-t , --type | Optional | [private ] |
--init | Optional | Boolean |
--gitignore | Optional | String |
--homepage | Optional | String |
--description | Optional | String |
Examples
gh re --new foo --clone
```
gh re --new foo --organization node-gh
```
gh re --new gemified --gitignore Ruby
```
gh re --new foo --init --type private
```
4. Fork
Option | Usage | Type |
---|
-f , --fork | Required | String |
-u , --user | Required | String |
-O , --organization | Optional | Boolean |
Examples
gh re --fork repo --user user
```
gh re --fork repo --user user --organization node-gh
```
5. Delete
Option | Usage | Type |
---|
-D , --delete | Required | String |
-u , --user | Required | String |
Example
gh re --delete foo
```
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
gh gi
```
gh gi --browser --id 5991877
```
2. List
Option | Usage | Type |
---|
-l , --list | Required | Boolean |
-u , --user | Optional | String |
Examples
gh gi --list
```
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
gh gi --new hello --content "Hello World!"
```
gh gi --new hello --content "Hello World!" --private
```
4. Fork
Option | Usage | Type |
---|
-f , --fork | Required | String |
Examples
gh gi --fork 5444883
```
5. Delete
Option | Usage | Type |
---|
-D , --delete | Required | String |
Example
gh gi --delete 4252323
```
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
gh user --login
```
gh user --logout
```
2. Whoami
Option | Usage | Type |
---|
-w , --whoami | Required | Boolean |
Examples
gh user --whoami
```
Alias
gh alias
Alias: gh al
1. List
Option | Usage | Type |
---|
-l , --list | Required | Boolean |
Examples
gh alias
```
gh alias --list
```
2. Add
Option | Usage | Type |
---|
-a , --add | Required | String |
-u , --user | Required | String |
Examples
gh alias --add zeno --user zenorocha
```
3. Remove
Option | Usage | Type |
---|
-r , --remove | Required | String |
Examples
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.
"api": {
"host": "api.github.com",
"protocol": "https",
"version": "3.0.0",
"pathPrefix": null
}
```
"default_branch": "master",
"default_remote": "origin"
```
"default_pr_forwarder": "",
"default_pr_reviewer": ""
```
"github_token": "",
"github_user": ""
```
"hooks": {
"pull-request": {
"merge": {
"before": [{"cmd": "ls -la", "log": true}],
"after": [
"gh pr {{options.number}} --comment 'Thank you, pull request merged :D'"
]
}
}
}
```
"hooks": {
"pull-request": {
"merge": {
"before": [{"cmd": "foo", "args": ["bar", "qux"]}]
}
}
}
```
"pull_branch_name_prefix": "pr-"
```
"signature": "
:octocat: Sent from GH."
```
If you need to use a custom git command, set the environment variable GH_GIT_COMMAND
.
Plugins
- GH Gif - A plugin for commenting on pull requests/issues using GIF reactions.
- GH Travis - A plugin for integrating Travis, a continous integration server.
- GH Jira - A plugin for integrating Jira, an issue management system.
Feel free to create your own plugins by forking GH Boilerplate.
Developer Tasks
lint
Detect errors on the code or its style using JSHint and JSCHcomplexity
Show code complexity analysis summaryplato
Create advanced code complexity static analysis in HTMLunit
Run unit tests and create code coverage report in HTMLtest
Run all code quality toolscoverage-report
Open code coverage reportplato-report
Open code complexity and static analysis reportwatch
Watch for any changes and run linting and tests
Team
Node GH is maintained by these guys and some awesome contributors.
Contributing
For detailed instructions, check Contributing. Don't miss the source code reports.
History
For detailed changelog, check Releases.
License
BSD License