Practical Git via GitExtensions
  • Git - a Distributed System
  • Bare Minimal Configurations
  • Creating a New Branch
  • Making a Commit
    • Adding only a portion of a file
    • Commit Message
    • Cherry-pick
    • Revert
  • Rewriting History
    • Rewording the Last Commit
    • Rewording Commit Message in Middle
    • Editing the Last Commit
    • Squashing Last Few Commits
    • Squashing Commits in Middle
    • Spliting Commit into Multiple
    • Removing a Commit
    • Pushing after Rewriting History
  • Lost and Found
  • Comparing Commits or Branches
  • Checking out a Branch into Another Folder
  • Blaming History
    • Blame
    • Bisect
  • Disabling Auto Tracking Branch
  • Line Ending
  • Ignore Unwanted Files
Powered by GitBook
On this page

Was this helpful?

  1. Making a Commit

Cherry-pick

PreviousCommit MessageNextRevert

Last updated 6 years ago

Was this helpful?

Cherry-pick, essentially, will duplicate the changes from the original commit to a new commit of the current branch.

It is useful but not limited to such scenarios

  • When sometimes we want some but not all the commits from a branch, for example, porting back a bug fix from v2.0 to v1.8.

  • When we were too lazy or forgot to create a new branch for the commits, and after finished the work we realized the commits were done on the wrong branch. We'd like to create a new branch basing on the right commit/branch and cherry-pick these commits.

  • Sometimes it's much faster than a rebase. For example when master branch is way ahead from our current branch, rebasing will need to evaluate all the commits in between which is slow.

To cherry-pick in GitExtensions, first we select a couple of commits to cherry-pick (the order doesn't matter, GitExtensions always does the oldest one first), then right click to popup the context menu and select Cherry-Pick menu item. BTW, you can hold the CTRL key to select multiple commits.

Unticking the Automatically create a commit will only pick up the changes but not create the commit.

Ticking the Add commit reference to commit message will put the original commit SHA as part of the new commit message body. It's no point to

Command line

git cherry-pick <Commit SHA> [Another Commit SHA]
# use the -x switch to add commit reference to original commit
git cherry-pick -x <Commit SHA> [Another Commit SHA]