Blog Hoch
Feb 2026·2 tup leghDe'wI' chenmoHta'

Git Rebase vs Merge: nuq lo'

#git#workflow

git merge 'ej git rebase feature branch changes main Daq nob. yIch rap: Hoch pIm Sovbe', history tangled pagh rewritten (neH pagh). cha' mIw Qagh rap 'ach pIm: Qagh mIw lo' vaj force-push disaster pagh unreadable commit graph.

wa'-wa' nuq Qu'

main choH (branch qaSpa'), feature branch commits ghaj:

      A---B---C  feature
     /
D---E---F---G  main

Merge chu' commit chenmoH, cha' histories bind, cha' parents:

git checkout feature
git merge main
      A---B---C-------H  feature
     /               /
D---E---F---G--------  main

A, B, C choHbe'. H merge commit chu': "cha' history lines DaH bind". full history (F G qaSpa' branch) Dach.

Rebase commits tlhap 'ej wa'-wa' new base Daq replay:

git checkout feature
git rebase main
D---E---F---G---A'---B'---C'  feature

A', B', C' chu' commits - changes rap, messages rap, parent pIm, hashes pIm. branch point Qaw'; G vo' branch 'ej wej commits straight line ghItlh legh.

distinction qatlh

core trade-off: merge real qaS preserve; rebase cleaner history chenmoH (literal qaS pagh). cha' Dun - audiences pIm.

  • Merge parallel work honest. cha' people old main Daq build, branches diverge reconverge vaj merge commit truth record. non-destructive: commit choH pagh. shared branches Daq safe.
  • Rebase history serial legh. git log clean line (merge lattice pagh). 'ach commit hashes rewrite - danger.

qatlh rule: shared history rebase Qo'

git checkout feature
git rebase main
git push --force-with-lease

feature SoH neH Qu' vaj Dun. feature (pagh main) others pull 'ej build vaj rebase history rewrite: local branch remote diverge, next pull tangle pagh local commits vanish (vanish pagh - branch reachable pagh).

rule: branches SoH neH push rebase freely; shared merge (pagh rebase-and-fast-forward PR tool).

interactive rebase: share qaSpa' cleanup

rebase Dung use: base pIm pagh - unpushed commits cleanup PR qaSpa'.

git rebase -i HEAD~4

editor poSmoH, loS commits list: reorder, squash "fix typo" "actually fix typo", messages reword - others legh qaSpa'. safest common use: messy work-in-progress history coherent commits choH.

merge conflicts pIm

merge conflicts wa'logh resolve. rebase commits law' same lines touch vaj conflict repeat (commit Hoch) - tedious 'ach precise: historical change context Daq resolve.

git rebase main
# CONFLICT in commit B
# ...resolve...
git add .
git rebase --continue
# CONFLICT in commit C, same lines
# ...resolve again...
git add .
git rebase --continue

rebase repeated-conflict slog vaj git rebase --abort start Daq nob. qaw!

practical default

  • own feature branch, main catch up: rebase.
  • PR qaSpa' commits cleanup: rebase -i.
  • finished reviewed feature main Daq: team convention - cha' Dun, consistency qatlh.
  • pushed (pagh pulled): merge, pagh rebase team agreement rap.

yaj

Merge parallel history truth (tangled graph). Rebase clean linear graph (commit identity rewrite). "nuq Dun" pagh - commits rewrite SoH neH ghaH'a'.

chu'N+1 Query Qagh 'ej chay' QotlhqanSafe idempotent database migrations ghItlh