Rebase moves your branch's commits so they appear to start from the tip of another branch — resulting in a linear history:
Before rebase:
main: A ─ B ─ C
feature: A ─ D ─ E
After: git switch feature && git rebase main
main: A ─ B ─ C
feature: A ─ B ─ C ─ D' ─ E' (D, E replayed on top of C)
git switch feature
git rebase main # rebase feature onto latest main
# If conflicts arise:
# 1. resolve the file
# git add resolved-file
# git rebase --continue # continue
# git rebase --abort # cancel and go back
merge — preserves full history, adds merge commit, non-destructiverebase — creates linear history, rewrites commits, cleaner logGolden rule: Never rebase public/shared branches — only your private feature branches.
Main has moved ahead by one commit after you branched. Rebase feature onto the latest main.
Click "Run" to execute your code.