La CLI oficial de GitHub (gh) permite interactuar con GitHub directamente desde la línea de comandos: crear y clonar repos, gestionar issues y Pull Requests, ver el estado de GitHub Actions y mucho más, sin abrir el navegador.
# Con winget (recomendado)
winget install GitHub.cli
# Con Chocolatey
choco install gh -y
# Con Scoop
scoop install gh
gh auth login
# Sigue las instrucciones: elige GitHub.com, HTTPS o SSH, y autentícate via navegador
| Categoría | Comando | Acción |
|---|---|---|
| Repos | gh repo create mi-repo --public | Crear repositorio nuevo |
| Repos | gh repo clone usuario/repo | Clonar repositorio |
| Repos | gh repo list --limit 20 | Listar tus repos |
| Repos | gh repo view --web | Abrir repo en el navegador |
| Issues | gh issue list | Ver issues abiertos |
| Issues | gh issue create --title "Bug" --body "Descripción" | Crear issue |
| Issues | gh issue close 42 | Cerrar issue #42 |
| PRs | gh pr create --fill | Crear PR con info del commit |
| PRs | gh pr list | Ver PRs abiertos |
| PRs | gh pr merge 15 --squash | Mergear PR #15 con squash |
| Actions | gh run list | Ver ejecuciones recientes |
| Actions | gh run watch | Seguir ejecución activa |
| Actions | gh workflow run deploy.yml | Disparar workflow manualmente |
Crea un repositorio público en GitHub llamado "mi-api-rest", inicializa Git en C:\proyectos\mi-api-rest, haz el primer commit con un README y sube el código
# 1. Crear rama de feature
git switch -c feature/nueva-funcionalidad
# 2. Hacer cambios y commit
git add . && git commit -m "feat: nueva funcionalidad"
# 3. Push y abrir PR en un solo comando
git push -u origin feature/nueva-funcionalidad
gh pr create --title "Nueva funcionalidad" --body "Descripción detallada" --label "enhancement"
gh pr diff 42 para obtener el diff y lo analiza automáticamente.