Cherry-Pick Commits Between Branches
You can cherry-pick commits when you want to apply a commit from one branch to another in your workspace. Typically, you'd cherry-pick commits from a remote branch to the working branch in your workspace.
Cherry-picking is useful when you work with multiple Git branches in a repository, either on your own or in a team environment. When you only need a specific commit from another branch, it's easier to cherry-pick that commit, instead of merging that entire branch to a remote repository. You can cherry-pick commits only between branches in the same repo.
Get the Revision ID of a Commit
Before you can cherry-pick a commit, you'll need the ID of the revision you want to include in your branch.
- If the commit is local to your workspace, follow these steps:
- If you or one of your teammates already pushed the commit to a remote
repository, follow these steps:
Cherry-Pick a Commit From Another Branch
Once you have a commit's revision ID, you can cherry-pick it to your working branch. Make sure you select the correct branch to cherry-pick the commit.
To cherry-pick a commit to your working branch: