Cherry-pick & Tags
git cherry-pick
Sometimes you don't want an entire branch's worth of commits - you want just one specific commit from another branch, applied on top of your current branch, without merging or rebasing everything else that branch contains.
$ git cherry-pick a1b2c3d
Scenario: A critical bug fix landed on thedevelopbranch as one commit, buried among ten others that aren't ready for production yet. Production (main) needs just that one fix, right now.cherry-pickcopies that single commit's changes over as a brand-new commit onmain, leaving develop's other unfinished work behind.
Under the hood, cherry-pick works much like a tiny rebase of one commit: Git takes that commit's changes and tries to reapply them on top of wherever you are now. If the surrounding code has diverged enough, it can conflict, exactly like a merge - resolve it the same way (edit, git add, git cherry-pick --continue).
Tags - marking releases
A tag is a permanent, human-readable label pointing at one specific commit - most commonly used to mark version releases (v1.0.0). Unlike a branch, a tag's pointer never moves once created; it's meant to forever mean "this exact commit was release 1.0.0".
| Command | Does |
|---|---|
git tag v1.0.0 | Lightweight tag on the current commit - just a name, nothing else |
git tag -a v1.0.0 -m "Release 1.0" | Annotated tag (recommended) - also stores who created it, when, and a message |
git tag | List all tags |
git push origin v1.0.0 | Push a tag (tags aren't pushed by default) |
Tip: Tags are not pushed automatically along with commits or branches - a plaingit pushnever sends them. Remembergit push origin <tag>(orgit push --tagsfor all of them at once), or your release marker exists only on your own machine.