Qué significa "lineal"
Un historial lineal no tiene merge commits — cada commit tiene exactamente un padre, y la historia es una sola línea desde el commit inicial hasta HEAD.
Por qué importa lineal
git bisectrecorre un camino, no un grafo.git log --onelinedice la verdad sin--graph.git revertapunta a un solo commit limpiamente.- Los revisores ven un cambio lógico por commit.
Lograr linealidad localmente
git checkout feature/login
git fetch origin
git rebase origin/main
git push --force-with-lease
Aplicar en el remote
En GitHub: branch protection rules → "Require linear history".
- Rebase and merge - reproduce los commits del branch sobre main individualmente.
- Squash and merge - aplana el branch a un solo commit en main.
- Fast-forward only - requiere que el branch ya esté actualizado.
Aplicación local
git config --global pull.rebase true
git config --global pull.ff only
git config --global rebase.autoStash true
Squash vs rebase merge
# Squash and merge: 1 commit en main por PR
git merge --squash feature/login
git commit -m "Add OAuth login"
# Rebase and merge: cada commit en main
git rebase main feature/login
git checkout main
git merge --ff-only feature/login
Detectar historial no lineal
git log --merges
git log --first-parent --oneline