GitHub CLI brings the GitHub to the terminal1. GitHub CLI & hub.
brew install gh
-
# list of prs involving me gh search prs --state=open --involves=@me # search by PR title gh pr list -S "state:open type:pr in:name IPM" # looking for things related to me gh pr list -S "is:open type:pr involves:@me" # view PR using a pager PAGER=less gh pr view 13992
gh api <endpoint> [flags]
- https://cli.github.com/manual/gh_api
--hostname <string>
- the GitHub hostname for the request (default “github.com”)
-
gh api graphql -F owner='{owner}' -F name='{repo}' -f query=' query($name: String!, $owner: String!) { repository(owner: $owner, name: $name) { releases(last: 3) { nodes { tagName } } } } '
gh auth login
gh repo --help
gh issue create
gh issue list
gh label list [flags]
gh label list --sort name
gh label list --search bug
gh pr
- https://cli.github.com/manual/gh_pr
-R
,--repo <[HOST/]OWNER/REPO>
- select another repository using the [HOST/]OWNER/REPO format
gh pr list
[flags]
- https://cli.github.com/manual/gh_pr_list
-a
,--assignee <string>
-A
,--author <string>
-L
,--limit <int>
-S
,--search <query>
-s
,--state <string>
- filter by state:
{open|closed|merged|all}
- filter by state:
gh pr create
gh pr view [<number> | <url> | <branch>] [flags]
-c
,--comments
- view pull request comments
gh pr review
[<number> | <url> | <branch>] [flags]
-a
,--approve
-b
,--body <string>
- specify the body of a review
-c
,--comment
-r
,--request-changes
- https://cli.github.com/manual/gh_pr
-
# ALIAS gh alias set all-with-me 'search prs --state=open --involves=@me' gh alias set with-me 'pr list -S "is:open type:pr involves:@me"'
GitHub Search Queries
GitHub Search Tips
to exclude something prepend a hyphen (-
):
foo_library -repo:owner1/repoX -repo:owner2/repo
- basic
is:issue
is:open
is:public
is:private
label:beginner
type:issue
type:pr
no:project
no:milestone
no:label
no:assignee
-
further more...
- find by people
involves:octocat
author:octocat
user:octocat
commenter:octocat
answered-by:octocat
assignee:octocat
- find by content through name, description/readme, and so on
in:name
in:title
in:description
in:readme
in:topic
in:body
in:comments
- find by date:
YYYY-MM-DD
- use
<
,>
,>=
,<=
and..
created:<2022-10-01
updated:>2022-10-01
merged:>=2022-10-01
closed:<=2022-10-01
closed:2024-05-01..2024-05-09
- use
- find numbers through stars, forks, and so on
- to further narrow your search use:
<
,>
,<=
,>=
&..
stars:n
stars:1000
forks:n
forks:<100
comments:n
- to further narrow your search use:
- miscellaneous
org:freecodecamp
language:LANGUAGE
language:PHP
license:LICENSE_KEYWORD
license:MIT
in:path user.rb
orfilename:user.rb
sort:reactions-+1-desc
state:open
draft:false
- additional resources:
- find by people