Git Reference
Git Reference / Cherry-pick & patches

13Cherry-pick & patches

Cherry-pick

Copy specific commits onto the current branch.

git cherry-pick a1b2c3d
git cherry-pick a1b2c3d..f6e5d4c   # range
git cherry-pick -x a1b2c3d         # note origin in message
git cherry-pick --no-commit a1b2c3d

Patches by email / file

Share commits without a shared remote.

git format-patch -3            # last 3 commits → .patch files
git am *.patch                 # apply as commits
git diff > change.diff
git apply change.diff          # apply as unstaged changes

Compare two versions of a branch

See what changed between rebases of a PR.

git range-diff main feature@{1} feature