Merge vs rebase vs cherry-pick?
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn Merge vs rebase vs cherry-pick?
Definition:
Merge, rebase and cherry-pick integrate changes through different history operations. Merge combines histories, rebase recreates commits on a new base, and cherry-pick recreates selected changes on the current branch. Recreated commits receive new IDs, which matters when other people already depend on the old history.
Key points:
-
Merge combines branch histories without rewriting existing commits.
-
Rebase replays commits on a new base and changes their IDs.
-
Cherry-pick applies one selected commit; avoid rebasing shared history without coordination.
-
A linear history can be useful, but shared-branch coordination matters more than a visually tidy commit graph.
Interview point:
- Explain when preserving history is important and why rewriting shared commits can disrupt collaborators.
Adapted from 09_TESTING_GIT_DOCKER_CLOUD.md · “Merge vs rebase vs cherry-pick?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.