gh auth login # authenticate (browser or token)gh auth status # who am I / which accountsgh auth switch # switch between logged-in accountsgh auth token # print current token (feed to other tools)gh auth refresh -s project # add an OAuth scope (e.g. project)gh auth setup-git # use gh as git's HTTPS credential helper
Repositories
gh repo create my-app --private --source=. --remote=origin --pushgh repo clone owner/name # clone (owner/name or URL)gh repo fork --clone # fork + clone in one stepgh repo view --web # open repo in browsergh repo view owner/name # README + metadata in terminalgh repo list owner --limit 50 # list a user/org's reposgh repo set-default owner/name # pin the default repo for this dirgh browse # open current repo; `gh browse 42` β issue/PRgh browse src/main.c:120 # open a file at a line on GitHub
Issues
gh issue create -t "Title" -b "Body" -l bug -a @me # create with title/body/label/assigneegh issue list --state open --label bug --assignee @megh issue view 42 # read #42; add --web for browsergh issue status # issues relevant to yough issue comment 42 -b "On it."gh issue edit 42 --add-label wip --milestone v2.0gh issue close 42 --comment "Fixed in #51."gh issue reopen 42gh issue develop 42 --checkout # create+checkout a branch for issue #42
Pull requests
gh pr create -t "Title" -b "Closes #42." # open a PR from current branchgh pr create --fill # title/body from commitsgh pr create --draft # open as draftgh pr list --state open --label buggh pr status # PRs: yours, assigned, needing reviewgh pr view 51 # add --web for browsergh pr checkout 51 # check out PR #51 locally to test itgh pr diff 51 # view the diffgh pr checks 51 # watch CI status checksgh pr review 51 --approve # or --request-changes -b "..." / --commentgh pr comment 51 -b "LGTM."gh pr ready 51 # mark a draft as ready for reviewgh pr merge 51 --squash --delete-branch # --merge / --rebase / --auto
gh workflow list # workflows in this repogh workflow run deploy.yml -f env=prod # manually trigger (workflow_dispatch)gh workflow enable deploy.yml # or disablegh run list --workflow deploy.yml # recent runsgh run view 12345 --log # full logsgh run view 12345 --log-failed # only failed stepsgh run watch 12345 # live status until it finishesgh run rerun 12345 --failed # retry only the failed jobsgh run download 12345 # download run artifacts