Practical Git replay/merge patterns for feature branches.
Merge (preserves history, adds merge commit)
git checkout main
git pull
git merge feature/login
Rebase (linear history on top of main)
git checkout feature/login
git fetch origin
git rebase origin/main
Pull with rebase (local habit)
git pull --rebase origin main
Interactive rebase (last N commits)
git rebase -i HEAD~3
In the todo list: squash, fixup, reword, drop — then resolve conflicts if prompted.
During conflict
git status
# edit files
git add -p
git rebase --continue
# or abort
git rebase --abort
Golden rules
- Do not rewrite history on shared branches unless the team agrees (then use
--force-with-leasecarefully). git refloghelps after a mistaken reset.