@icarusmx/creta 1.5.14 → 1.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +476 -74
- package/bin/creta.js +15 -1
- package/lib/data/command-help/lz.js +40 -30
- package/lib/exercises/13-shell-aliases.md +183 -38
- package/lib/exercises/14-gh-fundamentals.md +976 -0
- package/lib/exercises/API_CHANGES.md +193 -0
- package/lib/exercises/utils/README.md +114 -0
- package/lib/exercises/utils/lz-functions.sh +240 -0
- package/lib/readers/exercise-reader.js +285 -0
- package/package.json +1 -1
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
# GitHub CLI Fundamentals - De Instalación a Upstream
|
|
2
|
+
|
|
3
|
+
<!-- vim: set foldmethod=marker foldlevel=0: -->
|
|
4
|
+
|
|
5
|
+
## 📖 LazyVim Reading Guide {{{
|
|
6
|
+
|
|
7
|
+
**Start with:** `zM` (close all folds) → Navigate with `za` (toggle fold under cursor)
|
|
8
|
+
|
|
9
|
+
This document uses fold markers `{{{` and `}}}` for organized reading.
|
|
10
|
+
|
|
11
|
+
}}}
|
|
12
|
+
|
|
13
|
+
## 🎯 ¿Qué es GitHub CLI? {{{
|
|
14
|
+
|
|
15
|
+
**GitHub CLI (`gh`)** es la herramienta oficial de GitHub para trabajar con repos, issues, PRs y más desde la terminal.
|
|
16
|
+
|
|
17
|
+
**¿Por qué usar `gh` en vez de solo `git`?**
|
|
18
|
+
- `git` maneja control de versiones local y sync con remotes
|
|
19
|
+
- `gh` maneja la **plataforma GitHub**: repos, issues, PRs, workflows, releases
|
|
20
|
+
- Juntos son un equipo completo
|
|
21
|
+
|
|
22
|
+
**Flujo típico:**
|
|
23
|
+
```bash
|
|
24
|
+
# gh crea el repo en GitHub
|
|
25
|
+
gh repo create my-project --public
|
|
26
|
+
|
|
27
|
+
# git maneja commits y sync
|
|
28
|
+
git add .
|
|
29
|
+
git commit -m "first commit"
|
|
30
|
+
git push
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
}}}
|
|
34
|
+
|
|
35
|
+
## 🍺 Instalación con Homebrew {{{
|
|
36
|
+
|
|
37
|
+
### macOS/Linux {{{
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Instalar GitHub CLI
|
|
41
|
+
brew install gh
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Verificar instalación:**
|
|
45
|
+
```bash
|
|
46
|
+
gh --version
|
|
47
|
+
# Output: gh version 2.40.0 (o superior)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
}}}
|
|
51
|
+
|
|
52
|
+
### ¿Qué se instaló? {{{
|
|
53
|
+
|
|
54
|
+
Homebrew instaló:
|
|
55
|
+
- **Binario `gh`**: El ejecutable principal
|
|
56
|
+
- **Man pages**: Documentación (`man gh`)
|
|
57
|
+
- **Shell completions**: Autocompletado para tu shell
|
|
58
|
+
|
|
59
|
+
**Ubicación del binario:**
|
|
60
|
+
```bash
|
|
61
|
+
which gh
|
|
62
|
+
# Output: /opt/homebrew/bin/gh (Apple Silicon)
|
|
63
|
+
# or: /usr/local/bin/gh (Intel)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
}}}
|
|
67
|
+
|
|
68
|
+
### Windows (Opcional) {{{
|
|
69
|
+
|
|
70
|
+
Si usas Windows, instala con:
|
|
71
|
+
```powershell
|
|
72
|
+
# Con winget
|
|
73
|
+
winget install --id GitHub.cli
|
|
74
|
+
|
|
75
|
+
# O con scoop
|
|
76
|
+
scoop install gh
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
}}}
|
|
80
|
+
|
|
81
|
+
}}}
|
|
82
|
+
|
|
83
|
+
## 🔐 Autenticación con GitHub {{{
|
|
84
|
+
|
|
85
|
+
### Login Interactivo {{{
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
gh auth login
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**El CLI te preguntará:**
|
|
92
|
+
|
|
93
|
+
**1. ¿Qué cuenta?**
|
|
94
|
+
```
|
|
95
|
+
? What account do you want to log into?
|
|
96
|
+
> GitHub.com
|
|
97
|
+
GitHub Enterprise Server
|
|
98
|
+
```
|
|
99
|
+
**→ Selecciona:** `GitHub.com`
|
|
100
|
+
|
|
101
|
+
**2. ¿Protocolo preferido?**
|
|
102
|
+
```
|
|
103
|
+
? What is your preferred protocol for Git operations?
|
|
104
|
+
HTTPS
|
|
105
|
+
> SSH
|
|
106
|
+
```
|
|
107
|
+
**→ Selecciona:** `SSH` (recomendado - más seguro)
|
|
108
|
+
|
|
109
|
+
**3. ¿Subir tu SSH key?**
|
|
110
|
+
```
|
|
111
|
+
? Upload your SSH public key to your GitHub account?
|
|
112
|
+
> /Users/guillermo/.ssh/id_ed25519.pub
|
|
113
|
+
Skip
|
|
114
|
+
```
|
|
115
|
+
**→ Selecciona:** Tu key existente (o genera una si no tienes)
|
|
116
|
+
|
|
117
|
+
**4. ¿Cómo autenticarte?**
|
|
118
|
+
```
|
|
119
|
+
? How would you like to authenticate GitHub CLI?
|
|
120
|
+
> Login with a web browser
|
|
121
|
+
Paste an authentication token
|
|
122
|
+
```
|
|
123
|
+
**→ Selecciona:** `Login with a web browser`
|
|
124
|
+
|
|
125
|
+
**5. Copia el código y presiona Enter**
|
|
126
|
+
```
|
|
127
|
+
! First copy your one-time code: XXXX-XXXX
|
|
128
|
+
Press Enter to open github.com in your browser...
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**6. Autoriza en el browser**
|
|
132
|
+
- Se abre automáticamente
|
|
133
|
+
- Pega el código
|
|
134
|
+
- Click "Authorize GitHub CLI"
|
|
135
|
+
|
|
136
|
+
**¡Listo!** ✅
|
|
137
|
+
```
|
|
138
|
+
✓ Authentication complete.
|
|
139
|
+
✓ Logged in as guillermo
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
}}}
|
|
143
|
+
|
|
144
|
+
### Verificar Autenticación {{{
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Ver tu usuario actual
|
|
148
|
+
gh auth status
|
|
149
|
+
|
|
150
|
+
# Output:
|
|
151
|
+
# github.com
|
|
152
|
+
# ✓ Logged in to github.com as guillermo (~/.config/gh/hosts.yml)
|
|
153
|
+
# ✓ Git operations for github.com configured to use ssh protocol.
|
|
154
|
+
# ✓ Token: gho_************************************
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Archivos de configuración:**
|
|
158
|
+
- `~/.config/gh/hosts.yml`: Credenciales
|
|
159
|
+
- `~/.gitconfig`: Se actualizó para usar SSH
|
|
160
|
+
|
|
161
|
+
}}}
|
|
162
|
+
|
|
163
|
+
### Troubleshooting Login {{{
|
|
164
|
+
|
|
165
|
+
**Problema: "Could not determine default authenticated user"**
|
|
166
|
+
```bash
|
|
167
|
+
# Solución: Re-autenticar
|
|
168
|
+
gh auth logout
|
|
169
|
+
gh auth login
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Problema: SSH key no encontrada**
|
|
173
|
+
```bash
|
|
174
|
+
# Generar nueva SSH key
|
|
175
|
+
ssh-keygen -t ed25519 -C "tu@email.com"
|
|
176
|
+
|
|
177
|
+
# Agregar a ssh-agent
|
|
178
|
+
eval "$(ssh-agent -s)"
|
|
179
|
+
ssh-add ~/.ssh/id_ed25519
|
|
180
|
+
|
|
181
|
+
# Reintentar login
|
|
182
|
+
gh auth login
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Problema: Token expiró**
|
|
186
|
+
```bash
|
|
187
|
+
# Refrescar token
|
|
188
|
+
gh auth refresh
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
}}}
|
|
192
|
+
|
|
193
|
+
}}}
|
|
194
|
+
|
|
195
|
+
## 📦 Crear un Nuevo Repositorio {{{
|
|
196
|
+
|
|
197
|
+
### Crear Repo Vacío (GitHub primero) {{{
|
|
198
|
+
|
|
199
|
+
**Escenario:** Empezar un proyecto nuevo completamente desde cero.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Crear repo público en GitHub
|
|
203
|
+
gh repo create my-awesome-project --public
|
|
204
|
+
|
|
205
|
+
# Output:
|
|
206
|
+
# ✓ Created repository guillermo/my-awesome-project on GitHub
|
|
207
|
+
# ? Clone the new repository locally? Yes
|
|
208
|
+
# Cloning into 'my-awesome-project'...
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Flags disponibles:**
|
|
212
|
+
- `--public`: Repo público (visible para todos)
|
|
213
|
+
- `--private`: Repo privado (solo tú y colaboradores)
|
|
214
|
+
- `--description "..."`: Descripción del proyecto
|
|
215
|
+
- `--gitignore node`: Agregar .gitignore para Node.js
|
|
216
|
+
- `--license mit`: Agregar licencia MIT
|
|
217
|
+
|
|
218
|
+
**Ejemplo completo:**
|
|
219
|
+
```bash
|
|
220
|
+
gh repo create creta-v2 \
|
|
221
|
+
--public \
|
|
222
|
+
--description "CLI companion for LATAM developers" \
|
|
223
|
+
--gitignore node \
|
|
224
|
+
--license mit
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
}}}
|
|
228
|
+
|
|
229
|
+
### Crear Repo con Clone Automático {{{
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Crear y clonar en un solo comando
|
|
233
|
+
gh repo create portfolio-site --public --clone
|
|
234
|
+
|
|
235
|
+
# El CLI:
|
|
236
|
+
# 1. Crea el repo en GitHub
|
|
237
|
+
# 2. Lo clona localmente
|
|
238
|
+
# 3. Ya estás dentro del directorio
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Ahora puedes empezar a trabajar:**
|
|
242
|
+
```bash
|
|
243
|
+
cd portfolio-site
|
|
244
|
+
echo "# My Portfolio" > README.md
|
|
245
|
+
git add .
|
|
246
|
+
git commit -m "initial commit"
|
|
247
|
+
git push
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
}}}
|
|
251
|
+
|
|
252
|
+
### Crear Repo desde Directorio Existente {{{
|
|
253
|
+
|
|
254
|
+
**Escenario:** Ya tienes código local y quieres subirlo a GitHub.
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# En tu proyecto existente
|
|
258
|
+
cd ~/projects/my-local-app
|
|
259
|
+
|
|
260
|
+
# Inicializar git si no lo has hecho
|
|
261
|
+
git init
|
|
262
|
+
|
|
263
|
+
# Crear commit inicial
|
|
264
|
+
git add .
|
|
265
|
+
git commit -m "initial commit"
|
|
266
|
+
|
|
267
|
+
# Crear repo en GitHub y conectarlo
|
|
268
|
+
gh repo create my-local-app --source=. --public --push
|
|
269
|
+
|
|
270
|
+
# El CLI:
|
|
271
|
+
# 1. Crea el repo en GitHub
|
|
272
|
+
# 2. Agrega el remote "origin"
|
|
273
|
+
# 3. Hace push automático
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Flags importantes:**
|
|
277
|
+
- `--source=.`: Usa el directorio actual
|
|
278
|
+
- `--push`: Push automático después de crear
|
|
279
|
+
- `--remote <name>`: Nombre del remote (default: origin)
|
|
280
|
+
|
|
281
|
+
}}}
|
|
282
|
+
|
|
283
|
+
### Crear Repo Interactivo {{{
|
|
284
|
+
|
|
285
|
+
Si prefieres que el CLI te pregunte cada opción:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
gh repo create
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**El CLI preguntará:**
|
|
292
|
+
1. ¿Nombre del repo?
|
|
293
|
+
2. ¿Descripción?
|
|
294
|
+
3. ¿Visibilidad (public/private)?
|
|
295
|
+
4. ¿Agregar .gitignore?
|
|
296
|
+
5. ¿Agregar licencia?
|
|
297
|
+
6. ¿Clonar localmente?
|
|
298
|
+
|
|
299
|
+
**Ideal para:** Cuando no estás seguro de las opciones.
|
|
300
|
+
|
|
301
|
+
}}}
|
|
302
|
+
|
|
303
|
+
}}}
|
|
304
|
+
|
|
305
|
+
## 🔗 Trabajar con Remotes {{{
|
|
306
|
+
|
|
307
|
+
### Ver Remotes Configurados {{{
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Ver remotes
|
|
311
|
+
git remote -v
|
|
312
|
+
|
|
313
|
+
# Output:
|
|
314
|
+
# origin git@github.com:guillermo/creta.git (fetch)
|
|
315
|
+
# origin git@github.com:guillermo/creta.git (push)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Partes de la URL SSH:**
|
|
319
|
+
- `git@github.com`: Servidor y protocolo
|
|
320
|
+
- `guillermo`: Tu username
|
|
321
|
+
- `creta.git`: Nombre del repo
|
|
322
|
+
|
|
323
|
+
}}}
|
|
324
|
+
|
|
325
|
+
### Agregar Remote Manualmente {{{
|
|
326
|
+
|
|
327
|
+
**Escenario:** Creaste el repo en GitHub desde el browser, no con `gh`.
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# Crear repo local
|
|
331
|
+
git init
|
|
332
|
+
git add .
|
|
333
|
+
git commit -m "initial commit"
|
|
334
|
+
|
|
335
|
+
# Agregar remote
|
|
336
|
+
git remote add origin git@github.com:guillermo/my-project.git
|
|
337
|
+
|
|
338
|
+
# Verificar
|
|
339
|
+
git remote -v
|
|
340
|
+
|
|
341
|
+
# Push inicial
|
|
342
|
+
git push -u origin main
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Anatomía del comando:**
|
|
346
|
+
- `git remote add`: Agregar nuevo remote
|
|
347
|
+
- `origin`: Nombre del remote (convención)
|
|
348
|
+
- URL: Dónde está el repo en GitHub
|
|
349
|
+
|
|
350
|
+
}}}
|
|
351
|
+
|
|
352
|
+
### Cambiar URL del Remote {{{
|
|
353
|
+
|
|
354
|
+
**Escenario:** Necesitas cambiar de HTTPS a SSH (o viceversa).
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
# Ver URL actual
|
|
358
|
+
git remote get-url origin
|
|
359
|
+
# https://github.com/guillermo/creta.git
|
|
360
|
+
|
|
361
|
+
# Cambiar a SSH
|
|
362
|
+
git remote set-url origin git@github.com:guillermo/creta.git
|
|
363
|
+
|
|
364
|
+
# Verificar
|
|
365
|
+
git remote get-url origin
|
|
366
|
+
# git@github.com:guillermo/creta.git
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**¿Por qué preferir SSH?**
|
|
370
|
+
- No pide password en cada push
|
|
371
|
+
- Más seguro
|
|
372
|
+
- Mejor para automatización
|
|
373
|
+
|
|
374
|
+
}}}
|
|
375
|
+
|
|
376
|
+
### Múltiples Remotes {{{
|
|
377
|
+
|
|
378
|
+
**Escenario:** Fork de un proyecto + tu copia personal.
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Remote por defecto (tu fork)
|
|
382
|
+
git remote add origin git@github.com:guillermo/awesome-project.git
|
|
383
|
+
|
|
384
|
+
# Remote del proyecto original (upstream)
|
|
385
|
+
git remote add upstream git@github.com:original-author/awesome-project.git
|
|
386
|
+
|
|
387
|
+
# Ver todos
|
|
388
|
+
git remote -v
|
|
389
|
+
# origin git@github.com:guillermo/awesome-project.git (fetch)
|
|
390
|
+
# origin git@github.com:guillermo/awesome-project.git (push)
|
|
391
|
+
# upstream git@github.com:original-author/awesome-project.git (fetch)
|
|
392
|
+
# upstream git@github.com:original-author/awesome-project.git (push)
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Uso típico:**
|
|
396
|
+
```bash
|
|
397
|
+
# Pull cambios del proyecto original
|
|
398
|
+
git fetch upstream
|
|
399
|
+
git merge upstream/main
|
|
400
|
+
|
|
401
|
+
# Push tus cambios a tu fork
|
|
402
|
+
git push origin feature-branch
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
}}}
|
|
406
|
+
|
|
407
|
+
}}}
|
|
408
|
+
|
|
409
|
+
## ⬆️ Configurar Upstream (Tracking Branch) {{{
|
|
410
|
+
|
|
411
|
+
### ¿Qué es Upstream? {{{
|
|
412
|
+
|
|
413
|
+
**Upstream** (también llamado "tracking branch") es la relación entre tu rama local y la rama remota.
|
|
414
|
+
|
|
415
|
+
**Sin upstream:**
|
|
416
|
+
```bash
|
|
417
|
+
git push
|
|
418
|
+
# fatal: The current branch main has no upstream branch.
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
**Con upstream:**
|
|
422
|
+
```bash
|
|
423
|
+
git push
|
|
424
|
+
# ✓ Todo funciona automáticamente
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
**Beneficios:**
|
|
428
|
+
- `git pull` sin argumentos (sabe de dónde jalar)
|
|
429
|
+
- `git push` sin argumentos (sabe a dónde empujar)
|
|
430
|
+
- `git status` muestra si estás adelante/atrás
|
|
431
|
+
|
|
432
|
+
}}}
|
|
433
|
+
|
|
434
|
+
### Set Upstream en Primer Push {{{
|
|
435
|
+
|
|
436
|
+
**Opción 1: Flag `-u` (más común)**
|
|
437
|
+
```bash
|
|
438
|
+
# Hacer push Y establecer upstream
|
|
439
|
+
git push -u origin main
|
|
440
|
+
|
|
441
|
+
# Output:
|
|
442
|
+
# Enumerating objects: 3, done.
|
|
443
|
+
# ...
|
|
444
|
+
# Branch 'main' set up to track remote branch 'main' from 'origin'.
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
**Ahora puedes usar:**
|
|
448
|
+
```bash
|
|
449
|
+
git push # En vez de: git push origin main
|
|
450
|
+
git pull # En vez de: git pull origin main
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
}}}
|
|
454
|
+
|
|
455
|
+
### Set Upstream sin Push {{{
|
|
456
|
+
|
|
457
|
+
**Opción 2: Comando explícito**
|
|
458
|
+
```bash
|
|
459
|
+
# Establecer upstream sin hacer push
|
|
460
|
+
git branch --set-upstream-to=origin/main main
|
|
461
|
+
|
|
462
|
+
# O la versión corta:
|
|
463
|
+
git branch -u origin/main main
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
**Uso típico:**
|
|
467
|
+
- Cuando la rama ya existe remotamente
|
|
468
|
+
- Después de `git clone`
|
|
469
|
+
- Para reconectar una rama
|
|
470
|
+
|
|
471
|
+
}}}
|
|
472
|
+
|
|
473
|
+
### Ver Upstream Configurado {{{
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Ver tracking info de todas las ramas
|
|
477
|
+
git branch -vv
|
|
478
|
+
|
|
479
|
+
# Output:
|
|
480
|
+
# * main 4093951 [origin/main] add new strategic route
|
|
481
|
+
# dev 1348508 [origin/dev: behind 2] add os fundamentals
|
|
482
|
+
# feature ddbd498 add refactor.txt file
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
**Interpretación:**
|
|
486
|
+
- `[origin/main]`: main trackea origin/main
|
|
487
|
+
- `[origin/dev: behind 2]`: dev está 2 commits atrás de origin/dev
|
|
488
|
+
- Sin `[]`: feature no tiene upstream
|
|
489
|
+
|
|
490
|
+
}}}
|
|
491
|
+
|
|
492
|
+
### Workflow con Upstream {{{
|
|
493
|
+
|
|
494
|
+
**Crear feature branch con upstream desde el inicio:**
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
# Crear branch local
|
|
498
|
+
git checkout -b feature/new-lesson
|
|
499
|
+
|
|
500
|
+
# Hacer algunos commits
|
|
501
|
+
git add .
|
|
502
|
+
git commit -m "add new lesson"
|
|
503
|
+
|
|
504
|
+
# Push con upstream
|
|
505
|
+
git push -u origin feature/new-lesson
|
|
506
|
+
|
|
507
|
+
# Output:
|
|
508
|
+
# Branch 'feature/new-lesson' set up to track remote branch 'feature/new-lesson' from 'origin'.
|
|
509
|
+
|
|
510
|
+
# Ahora todos los push/pull son simples
|
|
511
|
+
git push # ✅ Funciona automáticamente
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
}}}
|
|
515
|
+
|
|
516
|
+
### Cambiar Upstream de una Rama {{{
|
|
517
|
+
|
|
518
|
+
**Escenario:** Quieres que tu rama local trackee una rama remota diferente.
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
# Rama actual trackea origin/dev
|
|
522
|
+
git branch -vv
|
|
523
|
+
# * feature [origin/dev] WIP
|
|
524
|
+
|
|
525
|
+
# Cambiar a origin/main
|
|
526
|
+
git branch -u origin/main
|
|
527
|
+
|
|
528
|
+
# Verificar
|
|
529
|
+
git branch -vv
|
|
530
|
+
# * feature [origin/main: ahead 3] WIP
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
**Uso típico:** Re-basar feature branches.
|
|
534
|
+
|
|
535
|
+
}}}
|
|
536
|
+
|
|
537
|
+
}}}
|
|
538
|
+
|
|
539
|
+
## 🔄 Workflow Completo: De Cero a Deploy {{{
|
|
540
|
+
|
|
541
|
+
### Nuevo Proyecto desde Scratch {{{
|
|
542
|
+
|
|
543
|
+
```bash
|
|
544
|
+
# 1. Crear repo en GitHub
|
|
545
|
+
gh repo create my-app --public --gitignore node --license mit
|
|
546
|
+
|
|
547
|
+
# 2. Clone automático (el CLI pregunta)
|
|
548
|
+
# → Selecciona "Yes" cuando pregunte si clonar
|
|
549
|
+
|
|
550
|
+
# 3. Ya estás en el directorio
|
|
551
|
+
cd my-app
|
|
552
|
+
|
|
553
|
+
# 4. Crear código
|
|
554
|
+
echo "console.log('Hello Icarus')" > index.js
|
|
555
|
+
|
|
556
|
+
# 5. Commit
|
|
557
|
+
git add .
|
|
558
|
+
git commit -m "add hello world"
|
|
559
|
+
|
|
560
|
+
# 6. Push (upstream ya configurado por gh clone)
|
|
561
|
+
git push
|
|
562
|
+
|
|
563
|
+
# 7. Abrir repo en browser
|
|
564
|
+
gh repo view --web
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**¡Todo conectado automáticamente!** ✅
|
|
568
|
+
|
|
569
|
+
}}}
|
|
570
|
+
|
|
571
|
+
### Proyecto Existente → GitHub {{{
|
|
572
|
+
|
|
573
|
+
```bash
|
|
574
|
+
# 1. Inicializar git
|
|
575
|
+
cd ~/projects/existing-app
|
|
576
|
+
git init
|
|
577
|
+
git add .
|
|
578
|
+
git commit -m "initial commit"
|
|
579
|
+
|
|
580
|
+
# 2. Crear repo y push en un comando
|
|
581
|
+
gh repo create existing-app --source=. --public --push
|
|
582
|
+
|
|
583
|
+
# 3. Verificar que todo se subió
|
|
584
|
+
gh repo view --web
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
**El CLI se encarga de:**
|
|
588
|
+
- ✅ Crear repo en GitHub
|
|
589
|
+
- ✅ Agregar remote origin
|
|
590
|
+
- ✅ Configurar upstream
|
|
591
|
+
- ✅ Push automático
|
|
592
|
+
|
|
593
|
+
}}}
|
|
594
|
+
|
|
595
|
+
### Fork y Contribuir a Proyecto Existente {{{
|
|
596
|
+
|
|
597
|
+
```bash
|
|
598
|
+
# 1. Fork del proyecto original
|
|
599
|
+
gh repo fork original-author/cool-project --clone
|
|
600
|
+
|
|
601
|
+
# 2. Ya estás en el directorio
|
|
602
|
+
cd cool-project
|
|
603
|
+
|
|
604
|
+
# 3. Ver remotes configurados
|
|
605
|
+
git remote -v
|
|
606
|
+
# origin git@github.com:guillermo/cool-project.git (tu fork)
|
|
607
|
+
# upstream git@github.com:original-author/cool-project.git (original)
|
|
608
|
+
|
|
609
|
+
# 4. Crear feature branch
|
|
610
|
+
git checkout -b feature/add-spanish-docs
|
|
611
|
+
|
|
612
|
+
# 5. Hacer cambios
|
|
613
|
+
echo "# Documentación en Español" > README.es.md
|
|
614
|
+
git add .
|
|
615
|
+
git commit -m "add Spanish documentation"
|
|
616
|
+
|
|
617
|
+
# 6. Push a TU fork
|
|
618
|
+
git push -u origin feature/add-spanish-docs
|
|
619
|
+
|
|
620
|
+
# 7. Crear Pull Request
|
|
621
|
+
gh pr create --title "Add Spanish docs" --body "Docs for LATAM community"
|
|
622
|
+
|
|
623
|
+
# 8. Actualizar desde upstream (mantenerse al día)
|
|
624
|
+
git fetch upstream
|
|
625
|
+
git checkout main
|
|
626
|
+
git merge upstream/main
|
|
627
|
+
git push origin main
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
**Ventajas del workflow con `gh`:**
|
|
631
|
+
- Fork automático con remotes configurados
|
|
632
|
+
- PRs desde la terminal
|
|
633
|
+
- Seguimiento de issues y reviews sin browser
|
|
634
|
+
|
|
635
|
+
}}}
|
|
636
|
+
|
|
637
|
+
}}}
|
|
638
|
+
|
|
639
|
+
## 🛠️ Comandos Útiles de gh {{{
|
|
640
|
+
|
|
641
|
+
### Ver Info del Repo {{{
|
|
642
|
+
|
|
643
|
+
```bash
|
|
644
|
+
# Ver repo actual en browser
|
|
645
|
+
gh repo view --web
|
|
646
|
+
|
|
647
|
+
# Ver info del repo en terminal
|
|
648
|
+
gh repo view
|
|
649
|
+
|
|
650
|
+
# Ver repos de un usuario
|
|
651
|
+
gh repo list guillermo
|
|
652
|
+
|
|
653
|
+
# Ver repos de una org
|
|
654
|
+
gh repo list icarusmx
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
}}}
|
|
658
|
+
|
|
659
|
+
### Clonar Repos {{{
|
|
660
|
+
|
|
661
|
+
```bash
|
|
662
|
+
# Clone rápido (solo necesitas owner/repo)
|
|
663
|
+
gh repo clone guillermo/creta
|
|
664
|
+
|
|
665
|
+
# Equivalente a:
|
|
666
|
+
git clone git@github.com:guillermo/creta.git
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
}}}
|
|
670
|
+
|
|
671
|
+
### Trabajar con Issues {{{
|
|
672
|
+
|
|
673
|
+
```bash
|
|
674
|
+
# Crear issue
|
|
675
|
+
gh issue create --title "Bug in lesson 7" --body "Steps to reproduce..."
|
|
676
|
+
|
|
677
|
+
# Ver issues
|
|
678
|
+
gh issue list
|
|
679
|
+
|
|
680
|
+
# Ver issue específico
|
|
681
|
+
gh issue view 42
|
|
682
|
+
|
|
683
|
+
# Cerrar issue
|
|
684
|
+
gh issue close 42
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
}}}
|
|
688
|
+
|
|
689
|
+
### Trabajar con PRs {{{
|
|
690
|
+
|
|
691
|
+
```bash
|
|
692
|
+
# Crear PR
|
|
693
|
+
gh pr create --title "Fix typo" --body "Fixed Spanish typo in README"
|
|
694
|
+
|
|
695
|
+
# Ver PRs
|
|
696
|
+
gh pr list
|
|
697
|
+
|
|
698
|
+
# Ver PR específico
|
|
699
|
+
gh pr view 123
|
|
700
|
+
|
|
701
|
+
# Checkout a PR localmente (para probarla)
|
|
702
|
+
gh pr checkout 123
|
|
703
|
+
|
|
704
|
+
# Merge PR
|
|
705
|
+
gh pr merge 123
|
|
706
|
+
|
|
707
|
+
# Cerrar PR sin merge
|
|
708
|
+
gh pr close 123
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
}}}
|
|
712
|
+
|
|
713
|
+
### Releases {{{
|
|
714
|
+
|
|
715
|
+
```bash
|
|
716
|
+
# Crear release
|
|
717
|
+
gh release create v1.5.0 --title "Phase 2 Launch" --notes "Command reference system"
|
|
718
|
+
|
|
719
|
+
# Ver releases
|
|
720
|
+
gh release list
|
|
721
|
+
|
|
722
|
+
# Download assets de un release
|
|
723
|
+
gh release download v1.5.0
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
}}}
|
|
727
|
+
|
|
728
|
+
}}}
|
|
729
|
+
|
|
730
|
+
## 🧪 Ejercicio Práctico {{{
|
|
731
|
+
|
|
732
|
+
**Objetivo:** Crear un proyecto completo desde cero usando todo lo aprendido.
|
|
733
|
+
|
|
734
|
+
### Paso a Paso {{{
|
|
735
|
+
|
|
736
|
+
```bash
|
|
737
|
+
# 1. Crear proyecto
|
|
738
|
+
mkdir test-gh-workflow
|
|
739
|
+
cd test-gh-workflow
|
|
740
|
+
|
|
741
|
+
# 2. Setup inicial
|
|
742
|
+
echo "# Test GH Workflow" > README.md
|
|
743
|
+
echo "console.log('Testing gh')" > index.js
|
|
744
|
+
echo "node_modules/" > .gitignore
|
|
745
|
+
|
|
746
|
+
# 3. Git init
|
|
747
|
+
git init
|
|
748
|
+
git add .
|
|
749
|
+
git commit -m "initial commit"
|
|
750
|
+
|
|
751
|
+
# 4. Crear repo en GitHub y push
|
|
752
|
+
gh repo create test-gh-workflow --source=. --public --push
|
|
753
|
+
|
|
754
|
+
# 5. Crear feature branch
|
|
755
|
+
git checkout -b feature/add-docs
|
|
756
|
+
|
|
757
|
+
# 6. Agregar más contenido
|
|
758
|
+
echo "## How to Use" >> README.md
|
|
759
|
+
git add .
|
|
760
|
+
git commit -m "add usage docs"
|
|
761
|
+
|
|
762
|
+
# 7. Push con upstream
|
|
763
|
+
git push -u origin feature/add-docs
|
|
764
|
+
|
|
765
|
+
# 8. Crear PR
|
|
766
|
+
gh pr create --title "Add documentation" --body "Basic usage docs"
|
|
767
|
+
|
|
768
|
+
# 9. Ver el PR en browser
|
|
769
|
+
gh pr view --web
|
|
770
|
+
|
|
771
|
+
# 10. Merge desde terminal
|
|
772
|
+
gh pr merge --squash
|
|
773
|
+
|
|
774
|
+
# 11. Volver a main y pull
|
|
775
|
+
git checkout main
|
|
776
|
+
git pull
|
|
777
|
+
|
|
778
|
+
# 12. Ver el repo final
|
|
779
|
+
gh repo view --web
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
}}}
|
|
783
|
+
|
|
784
|
+
### Verificación {{{
|
|
785
|
+
|
|
786
|
+
**Checklist:** ✅ Deberías tener:
|
|
787
|
+
- [ ] Repo en GitHub
|
|
788
|
+
- [ ] Main branch con README e index.js
|
|
789
|
+
- [ ] PR mergeado en history
|
|
790
|
+
- [ ] Remote origin configurado
|
|
791
|
+
- [ ] Upstream configurado para main
|
|
792
|
+
- [ ] Todo visible en GitHub.com
|
|
793
|
+
|
|
794
|
+
**Limpieza (opcional):**
|
|
795
|
+
```bash
|
|
796
|
+
# Eliminar repo de prueba
|
|
797
|
+
gh repo delete test-gh-workflow --yes
|
|
798
|
+
|
|
799
|
+
# Eliminar directorio local
|
|
800
|
+
cd ..
|
|
801
|
+
rm -rf test-gh-workflow
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
}}}
|
|
805
|
+
|
|
806
|
+
}}}
|
|
807
|
+
|
|
808
|
+
## 🎓 Resumen: Git vs gh {{{
|
|
809
|
+
|
|
810
|
+
### git: Control de Versiones {{{
|
|
811
|
+
|
|
812
|
+
**Comandos que usas con `git`:**
|
|
813
|
+
- `git init` - Inicializar repo
|
|
814
|
+
- `git add` - Stage cambios
|
|
815
|
+
- `git commit` - Crear commits
|
|
816
|
+
- `git push` - Subir commits a remote
|
|
817
|
+
- `git pull` - Descargar cambios de remote
|
|
818
|
+
- `git branch` - Manejar ramas
|
|
819
|
+
- `git merge` - Combinar ramas
|
|
820
|
+
- `git remote` - Manejar remotes
|
|
821
|
+
|
|
822
|
+
**Filosofía:** Local-first, luego sync con remotes.
|
|
823
|
+
|
|
824
|
+
}}}
|
|
825
|
+
|
|
826
|
+
### gh: Plataforma GitHub {{{
|
|
827
|
+
|
|
828
|
+
**Comandos que usas con `gh`:**
|
|
829
|
+
- `gh repo create` - Crear repos en GitHub
|
|
830
|
+
- `gh repo fork` - Fork repos
|
|
831
|
+
- `gh pr create` - Crear Pull Requests
|
|
832
|
+
- `gh issue create` - Crear Issues
|
|
833
|
+
- `gh release create` - Crear Releases
|
|
834
|
+
- `gh auth login` - Autenticación
|
|
835
|
+
|
|
836
|
+
**Filosofía:** Automatizar workflows de GitHub desde terminal.
|
|
837
|
+
|
|
838
|
+
}}}
|
|
839
|
+
|
|
840
|
+
### Trabajan Juntos {{{
|
|
841
|
+
|
|
842
|
+
**Ejemplo combinado:**
|
|
843
|
+
```bash
|
|
844
|
+
# gh crea el repo en GitHub
|
|
845
|
+
gh repo create my-project --public
|
|
846
|
+
|
|
847
|
+
# git maneja el código
|
|
848
|
+
git add .
|
|
849
|
+
git commit -m "first feature"
|
|
850
|
+
|
|
851
|
+
# git empuja a GitHub
|
|
852
|
+
git push
|
|
853
|
+
|
|
854
|
+
# gh crea el PR
|
|
855
|
+
gh pr create --title "Add feature"
|
|
856
|
+
|
|
857
|
+
# gh mergea el PR
|
|
858
|
+
gh pr merge
|
|
859
|
+
|
|
860
|
+
# git actualiza tu local
|
|
861
|
+
git pull
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
**Pro tip:** Conoce cuándo usar cada uno. `git` para código, `gh` para plataforma.
|
|
865
|
+
|
|
866
|
+
}}}
|
|
867
|
+
|
|
868
|
+
}}}
|
|
869
|
+
|
|
870
|
+
## 📚 Quick Reference {{{
|
|
871
|
+
|
|
872
|
+
```bash
|
|
873
|
+
# === INSTALACIÓN ===
|
|
874
|
+
brew install gh
|
|
875
|
+
|
|
876
|
+
# === AUTENTICACIÓN ===
|
|
877
|
+
gh auth login # Login interactivo
|
|
878
|
+
gh auth status # Ver estado
|
|
879
|
+
gh auth logout # Logout
|
|
880
|
+
|
|
881
|
+
# === REPOS ===
|
|
882
|
+
gh repo create <name> --public # Crear repo público
|
|
883
|
+
gh repo create --source=. --push # Crear desde directorio actual
|
|
884
|
+
gh repo clone <owner>/<repo> # Clonar repo
|
|
885
|
+
gh repo view --web # Ver en browser
|
|
886
|
+
gh repo fork <owner>/<repo> # Fork con remotes configurados
|
|
887
|
+
|
|
888
|
+
# === REMOTES ===
|
|
889
|
+
git remote -v # Ver remotes
|
|
890
|
+
git remote add origin <url> # Agregar remote
|
|
891
|
+
git remote set-url origin <url> # Cambiar URL
|
|
892
|
+
|
|
893
|
+
# === UPSTREAM ===
|
|
894
|
+
git push -u origin main # Push + set upstream
|
|
895
|
+
git branch -u origin/main # Set upstream sin push
|
|
896
|
+
git branch -vv # Ver tracking info
|
|
897
|
+
|
|
898
|
+
# === WORKFLOW ===
|
|
899
|
+
gh pr create # Crear PR
|
|
900
|
+
gh pr list # Ver PRs
|
|
901
|
+
gh pr merge # Merge PR
|
|
902
|
+
gh issue create # Crear issue
|
|
903
|
+
gh release create <tag> # Crear release
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
}}}
|
|
907
|
+
|
|
908
|
+
## 💡 Mejores Prácticas {{{
|
|
909
|
+
|
|
910
|
+
### Do's ✅ {{{
|
|
911
|
+
|
|
912
|
+
1. **Usa SSH para repos** (más seguro, no pide password)
|
|
913
|
+
2. **Siempre usa `-u` en primer push** (configura upstream)
|
|
914
|
+
3. **Nombra remotes descriptivos** (origin, upstream, fork-name)
|
|
915
|
+
4. **Verifica authentication** antes de trabajar (`gh auth status`)
|
|
916
|
+
5. **Usa `gh` para crear repos** (configura todo automáticamente)
|
|
917
|
+
6. **Crea PRs desde la terminal** (faster workflow)
|
|
918
|
+
7. **Mantén upstream sincronizado** en forks
|
|
919
|
+
|
|
920
|
+
}}}
|
|
921
|
+
|
|
922
|
+
### Don'ts ❌ {{{
|
|
923
|
+
|
|
924
|
+
1. **No uses HTTPS si ya tienes SSH key** (menos eficiente)
|
|
925
|
+
2. **No olvides `-u` en primer push** (o tendrás que hacerlo después)
|
|
926
|
+
3. **No nombres remotes al azar** (usa convenciones: origin, upstream)
|
|
927
|
+
4. **No mezcles accounts** (verifica `gh auth status`)
|
|
928
|
+
5. **No hagas push a upstream** en forks (push a origin, PR a upstream)
|
|
929
|
+
6. **No ignores los mensajes de tracking** (son útiles)
|
|
930
|
+
|
|
931
|
+
}}}
|
|
932
|
+
|
|
933
|
+
### Pro Tips 🚀 {{{
|
|
934
|
+
|
|
935
|
+
**Aliases útiles:**
|
|
936
|
+
```bash
|
|
937
|
+
# Agregar a ~/.gitconfig
|
|
938
|
+
[alias]
|
|
939
|
+
pushup = push -u origin HEAD
|
|
940
|
+
track = branch -u origin/main
|
|
941
|
+
remotes = remote -v
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
**Ahora puedes:**
|
|
945
|
+
```bash
|
|
946
|
+
git pushup # Push con upstream automático
|
|
947
|
+
git track # Set tracking rápido
|
|
948
|
+
git remotes # Ver remotes (más corto)
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
**Workflow aliases para `gh`:**
|
|
952
|
+
```bash
|
|
953
|
+
# Agregar a ~/.zshrc o ~/.bashrc
|
|
954
|
+
alias ghc='gh repo create'
|
|
955
|
+
alias ghv='gh repo view --web'
|
|
956
|
+
alias prc='gh pr create'
|
|
957
|
+
alias prm='gh pr merge --squash'
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
}}}
|
|
961
|
+
|
|
962
|
+
}}}
|
|
963
|
+
|
|
964
|
+
## 🔗 Recursos Adicionales {{{
|
|
965
|
+
|
|
966
|
+
- **Docs oficiales:** `gh help` o https://cli.github.com
|
|
967
|
+
- **Man pages:** `man gh`, `man git-remote`
|
|
968
|
+
- **SSH setup:** https://docs.github.com/en/authentication/connecting-to-github-with-ssh
|
|
969
|
+
- **Git book:** https://git-scm.com/book/en/v2
|
|
970
|
+
- **Icarus exercises:** `creta sintaxis` para más lecciones
|
|
971
|
+
|
|
972
|
+
}}}
|
|
973
|
+
|
|
974
|
+
---
|
|
975
|
+
|
|
976
|
+
**Remember:** `gh` no reemplaza a `git`, lo complementa. Domina ambos para workflows eficientes. 🚀
|