Git in a Minute · intermediate

Git in a Minute: Rebase

Rebase replays commits onto a new base—useful for updating a branch, dangerous on shared history.

Last verified: 2026-09-06

In one sentence

Rebase takes commits from your branch and replays them on top of another tip, rewriting their parent history.

Why it matters

Agent branches go stale while models work. Rebase (or merge) brings them up to date before review. Used carelessly on shared branches, rebase creates duplicate commits and painful coordination.

How it works

Updating a private feature branch:

git fetch origin
git rebase origin/main

Resolve conflicts commit by commit. Prefer rebase on unpushed or single-owner branches. Prefer merge commits when multiple people already built on the branch tip.

Example

After an agent finishes on agent/fix-api, rebase onto latest main, re-run tests, then open or update the PR.

Agentic coding use

Teach agents (and humans) a policy: never force-push protected branches; only rewrite history you exclusively own. Automation that rebases must re-run verification after conflict resolution.

Watch out

rebase plus force-push on a branch others use will desync their worktrees. That failure mode is worse with multiple agents attached to the same branch name.

Sources