Site Tools


wiki:git-cherry-pick

Table of Contents

Git Cherry-picking

Cherry-picking applies a single commit from one branch to another. Instead of merging an entire branch, you select specific commits and replay them. This is useful for backporting bug fixes to an older release branch or copying a specific change without merging everything else the branch contains.

Run git cherry-pick <hash> to apply a commit on top of your current branch. Git replays the changes from that commit and creates a new commit with the same message and author. If there are conflicts, resolve them like in a merge and run git cherry-pick --continue. If something goes wrong, git cherry-pick --abort cancels the operation.

$ git cherry-pick <hash>     # apply a single commit
$ git cherry-pick <hash1> <hash2> # apply multiple commits
$ git cherry-pick --continue # resume after resolving conflicts
$ git cherry-pick --abort    # cancel a cherry-pick

Cherry-picking creates a new commit with a different hash, so the original commit and the cherry-picked copy are separate in history. This is fine for isolated bug fixes, but for merging entire features, always use git merge instead—it preserves the relationship between branches and makes history easier to follow.

wiki/git-cherry-pick.md · Last modified: by 127.0.0.1