DevTools

Cheatsheet GitHub CLI

Ferramenta de linha de comandos oficial do GitHub

Voltar às linguagens
GitHub CLI
22 cards encontrados
Categorias:
Versões:

Autenticação


3 cards
Login
gh auth login
gh auth status
gh auth token
gh auth refresh -s repo,read:org

Autenticar no GitHub.

Configuração
gh config set editor vim
gh config set git_protocol ssh
gh config list
gh alias set co 'pr checkout'

Configurar preferências.

Múltiplas contas
gh auth login --hostname github.com
gh auth switch
gh auth status --show-token

Gerir contas.

Repositórios


4 cards
Criar repositório
gh repo create meu-projeto --public
gh repo create --private --clone
gh repo create org/projeto --template base

Criar repos no GitHub.

Clonar e fork
gh repo clone user/repo
gh repo fork user/repo --clone
gh repo view --web

Obter repositórios.

Listar e ver
gh repo list
gh repo list --language=php
gh repo view user/repo
gh repo set-default

Explorar repositórios.

Gerir repo
gh repo edit --description "Nova desc"
gh repo rename novo-nome
gh repo delete user/repo --yes
gh repo archive user/repo

Modificar repositórios.

Pull Requests


4 cards
Criar PR
gh pr create
gh pr create --title "Fix bug" \
  --body "Descrição" --draft
gh pr create --base main --head feature

Criar pull request.

Listar e ver
gh pr list
gh pr list --state merged
gh pr view 42
gh pr view 42 --web
gh pr diff 42

Explorar PRs.

Checkout e merge
gh pr checkout 42
gh pr merge 42 --squash
gh pr merge 42 --rebase
gh pr merge 42 --merge --delete-branch

Trabalhar com PRs.

Review
gh pr review 42 --approve
gh pr review 42 --request-changes \
  --body "Corrigir X"
gh pr review 42 --comment
gh pr checks 42

Rever pull requests.

Issues


3 cards
Criar issue
gh issue create
gh issue create --title "Bug" \
  --body "Descrição" --label bug
gh issue create --assignee @me

Criar issues.

Listar e filtrar
gh issue list
gh issue list --label bug --state open
gh issue list --assignee @me
gh issue list --search "texto"

Filtrar issues.

Gerir issues
gh issue view 10
gh issue close 10 --reason completed
gh issue reopen 10
gh issue edit 10 --add-label urgent
gh issue comment 10 --body "Feito!"

Modificar issues.

Actions


4 cards
Listar workflows
gh workflow list
gh workflow view ci.yml
gh run list --workflow=ci.yml
gh run list --limit 5

Ver workflows e runs.

Ver runs
gh run view 12345
gh run view 12345 --log
gh run view 12345 --log-failed
gh run watch 12345

Inspecionar execuções.

Trigger e re-run
gh workflow run ci.yml
gh workflow run ci.yml -f param=val
gh run rerun 12345
gh run rerun 12345 --failed

Executar workflows.

Logs e artefactos
gh run download 12345
gh run download 12345 -n artifact-name
gh cache list
gh cache delete --all

Descarregar resultados.

Avançado


4 cards
Gists
gh gist create ficheiro.txt --public
gh gist list
gh gist view GIST_ID
gh gist edit GIST_ID

Gerir gists.

Releases
gh release create v1.0.0
gh release create v1.0.0 dist/* \
  --title "Release 1.0" \
  --notes "Changelog aqui"
gh release list
gh release download v1.0.0

Gerir releases.

API direta
gh api repos/user/repo
gh api graphql -f query='{ viewer { login } }'
gh api repos/user/repo/issues \
  --paginate --jq '.[].title'

Aceder à API do GitHub.

Extensões
gh extension install dlvhdr/gh-dash
gh extension list
gh extension remove gh-dash
gh dash  # dashboard TUI

Estender com extensões.