REFERENCE · GIT BASICS

Merge vs rebase

Understand history before making it tidy.

Merge joins histories

A normal merge preserves existing commits and, when branches diverged, creates a merge commit with both histories as parents. A fast-forward just moves a pointer.

git switch feature/menu
git merge main

Rebase replays commits

Rebase takes commits from your branch and reapplies them on another base, usually producing new commit identities. The working changes can be similar while the history shape differs.

git switch feature/menu
git rebase main

Do not surprise other people

Avoid rebasing commits other people already depend on unless your team explicitly coordinates it. Do not force-push just to make a graph look cleaner. Private feature work and shared history need different judgment.

Conflict recovery belongs to the operation

For a paused rebase, edit, stage and rebase --continue. Rebase --abort backs out of the rebase. Merge uses merge --abort; do not mix them up.

git add RESOLVED_FILE
git rebase --continue
# Or choose to cancel the operation:
git rebase --abort

Quick check

Which operation generally rewrites commit identities?

Choose an answer.

Sources and scope

Command blocks are syntax examples checked against official documentation, not fabricated terminal output. Replace uppercase placeholders with your actual names and inspect status before commands that change work.

git-merge · git-rebase ·

All references · Course map

Git, Visually · Reference