Working Directory → Staging Area → Repository (commits)
(editás) (git add) (git commit)
git status= el "pwd" de Git (antes y después de cada acción)git diff= working vs last commitgit diff --staged= staging vs last commit (lo que irá al commit)
git init
git status
git diff
git diff --staged
git add <archivo> # selectivo (commits atómicos)
git add -A # todo (cuidado con secretos)
git commit -m "fix: msg claro"
git log --oneline --graph.env
*.pem
*.key
*.log
logs/
build/
target/
node_modules/
.DS_StoreNunca git add -A sin mirar git status.
git branch
git checkout -b feature/x # crear + cambiar
git switch feature/x # moderno
git checkout main
git branch -d feature/x # solo si mergeada
git branch -D feature/x # forzadoEstrategia típica: main estable + feature/* + hotfix desde tag/release.
git checkout main
git merge feature/x| Tipo | Cuándo |
|---|---|
| Fast-forward | main no avanzó → mueve el puntero |
| 3-way | ambas branches avanzaron → merge commit |
| Conflicto | misma línea en ambos lados → resolver a mano |
git merge feature/x→ conflicto- Abrí el archivo: buscá
<<<<<<<=======>>>>>>> - Dejá la versión correcta
git add <archivo>git commit(cierra el merge)
| Merge | Rebase | |
|---|---|---|
| Historia | Preserva ramas (merge commit) | Lineal (reescribe commits) |
| Cuándo | Integrar features a main | Limpiar branch local antes de PR |
| Cuidado | Más ruidoso | Nunca rebasees commits ya pusheados compartidos |
git checkout feature/x
git rebase main # solo en branches tuyasgit cherry-pick <sha> # aplica UN commit a la branch actualÚtil: llevar un fix a main sin mergear toda la feature.
git tag -a v1.0.0 -m "Release 1.0.0"
git tag
git show v1.0.0
git diff v1.0.0 v1.1.0
git push origin v1.0.0
git push --tags- PATCH
v1.0.1— bugfix - MINOR
v1.1.0— feature compatible - MAJOR
v2.0.0— breaking change
git remote -v
git remote add origin <url>
git push -u origin main
git pull origin main
gh auth status
gh repo create
gh pr create --title "..." --body "..."
gh pr list
gh run list
gh run view <id> --logname: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# releases:
# push:
# tags: ['v*']
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./mvnw test # o npm test
build:
needs: test # fail-fast: solo si test OK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t app:${{ github.sha }} .Archivos en: .github/workflows/*.yml
- Settings → Secrets and variables → Actions
- Uso:
${{ secrets.MY_TOKEN }} - Nunca hardcodear passwords en YAML ni en Dockerfile
- Evitar
echode secrets en logs
strategy:
matrix:
java: [17, 21]
steps:
- uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}Corre el mismo job N veces en paralelo (compatibilidad).
| Tag | Uso |
|---|---|
:sha-abc1234 |
Trazabilidad exacta |
:v1.2.0 |
Release SemVer |
:latest |
Solo demos (no prod) |
- uses: docker/metadata-action@v5
- uses: docker/build-push-action@v6lint → test → build image → push registry → deploy staging → smoke → deploy prod (approval)
Buenas prácticas:
- Tests antes del build (fail-fast)
- Tag con SHA + SemVer
- Environment + required reviewers para prod
- Continuous Delivery (click) vs Continuous Deployment (auto)
| Síntoma | Qué mirar |
|---|---|
| Workflow no corre | path .github/workflows/, trigger on:, branch/tag |
| Job skipped | needs: falló upstream |
| Auth Docker/GHCR | secrets, docker/login-action |
| Tests OK local, fallan en CI | versiones matrix, env vars faltantes |
| Deploy no triggerea | ¿pusheaste tag? ¿environment protegido? |
gh run list
gh run view --log-failed