Por Anónimo (no verificado) , 29 Abril 2026

Tres estrategias, tres historias

Al integrar un branch feature a main, tienes tres opciones. Cada una produce una forma diferente de historia.

Merge commit

git checkout main
git merge --no-ff feature/login

Pros: preserva la verdad de cómo ocurrió el desarrollo.

Contras: historia no lineal.

Squash and merge

git checkout main
git merge --squash feature/login
git commit -m "Add OAuth login"

Pros: historia lineal; un commit por feature.

Contras: pierde detalle a nivel de commit.

Rebase and merge

git checkout feature/login
git rebase main
git checkout main
git merge --ff-only feature/login

Pros: lineal; preserva commits atómicos.

Contras: requiere disciplina.

Matriz de decisión

  • Proyecto estilo librería o kernel - rebase and merge.
  • App con contribuidores disciplinados - rebase and merge.
  • App con disciplinas mixtas - squash.
  • Proyecto donde branches paralelos importan - merge commits.

Configurar en el host

gh api -X PATCH repos/:owner/:repo \
  -F allow_merge_commit=false \
  -F allow_squash_merge=true \
  -F allow_rebase_merge=true

Equivalentes locales

git merge --no-ff feature
git merge --squash feature && git commit
git rebase main feature
git checkout main
git merge --ff-only feature

Revertir

  • Merge commit: git revert -m 1 <merge-sha>.
  • Squash: git revert <squash-sha>.
  • Rebase: git revert <sha1> <sha2>....