Merge workflow

Merge main into your feature branch

git checkout feature/login
git merge main

Example:

git merge --no-ff feature/login

Resolve conflicts then finish merge

git status
git add .
git commit

Example:

git merge --abort

Rebase workflow

Rebase feature branch onto main

git checkout feature/login
git rebase main

Example:

git rebase --continue

Interactive cleanup before push

git rebase -i HEAD~5

Example:

git push --force-with-lease

When to choose each

Preserve branch history with merge

git merge feature/login

Example:

git log --graph --oneline --all

Linear history with rebase

git rebase main

Example:

git log --oneline

Common mistakes / Pitfalls

  • Rebasing commits already pushed to shared branches causes history rewrite issues.
  • Forgetting --force-with-lease after rebase leads to rejected push confusion.
  • Using merge and rebase together randomly makes commit history hard to read.
Last updated: February 2026