advanced · 30 minute study
Replaying a change creates new history objects
Understand when replaying commits is useful and why the same operation becomes disruptive after others depend on the published history.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- Resolve the intended behavior, not just the markers — Two independently useful changes can conflict textually. Resolve them by preserving the agreed behavior and verifying the integrated result.
First, build a mental model
Rebase replays a line of work onto another base. Cherry-pick applies a selected commit's change to the current line. The new commits can carry similar patches while having different identities and dependency context.
- A commit's identity includes its tree, parents and metadata. Changing the parent context normally creates a new commit ID.
- Rebase is useful for an intentionally controlled development branch; shared history requires coordination because other people may depend on the original IDs.
- Cherry-pick selects a change rather than merging the whole branch, but the selected change may depend on earlier work.
- Conflicts must be resolved in the context of the operation; rebase --continue and cherry-pick --continue resume different workflows.
- A force-with-lease check is not permission to rewrite shared history. Respect protected branches, collaboration agreements and explicit publication authority.
# On a disposable or deliberately controlled unpublished feature branch:
git status
git switch feature/labels
git rebase main
# Inspect any replayed result and run relevant checks.
# A separate alternative for one reviewed, self-contained change:
# git switch target-branch
# git cherry-pick REVIEWED_COMMIT
# REVIEWED_COMMIT is a placeholder, not a supplied real commit ID.- Original context
The feature commits were created relative to their old parents.
- Replay
Rebase applies their changes after the selected new base.
- New candidate
The resulting commits have new identities and need integration verification in the new context.
Production thinking
Take this beyond the example.
Use replay deliberately, preserve a recovery reference when appropriate and retest the final candidate. Do not present a pre-rebase CI pass as proof of the post-rebase integrated snapshot.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · Undo a shared change without pretending it never happened →