Warm-up · from “Understanding and resolving conflicts”
Which Index stage is the base?
Which Index stage is the base?
No notes: write what you remember, then check. Recalling before reading is what makes it stick.
The problem
A bug fix exists on a development branch, but the production release needs only that fix. How do you bring it over without merging all development history?
After this lesson you can
Apply one ordinary commit to another branch.
Explain new identity.
Handle conflicts and abort.
Key terms
Full glossarySay what each term means, then open it to check.
Commit · from lesson 7
Object identifying a root tree, parent(s), metadata and message.
Visual mental model
- DevA → B → C
- ReleaseA → R
- Cherry-pick Capplies the change
- C′ on Rnew identity
Build the mental model
Cherry-pick takes the change introduced by a selected commit relative to its parent and applies it to the current history using Git's merge machinery. It normally creates a new commit whose parent is the current tip; the original commit remains. Since parent and other metadata can differ, the new ID generally differs even when the change is equivalent.
A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.
Under the hood
Use git cherry-pick COMMIT for a single ordinary commit. A merge commit requires choosing a mainline parent with -m, an advanced decision. If a conflict occurs, resolve and stage the result, then git cherry-pick --continue. --abort cancels the sequence. Inspect the selected change and its dependencies: a fix may assume code that is missing on the target branch.
Common mistake · important nuance
Cherry-pick transfers a change, not the whole branch's ancestry. Avoid duplicating changes unnecessarily across histories.