PyCharm 2016.1 Help

Applying Changes from a Specific Commit to Other Branches (Cherry Picking)

Suppose, you have two diverged branches, master and hotfix. One day, you decide to integrate changes from one specific commit in master to hotfix. With PyCharm, you can cherry pick between branches right from the Version Control tool window.

To cherry pick changes between two branches

  1. Switch to the target branch that the changes will be integrated to.
  2. Open the Version Control tool window and switch to the Log tab.
  3. From the Branch drop-down list on the toolbar, select the source branch containing the changes you want to cherry-pick.

    Note that the Commits pane lists all commits performed in the selected branch. To reduce the number of items in the list, you can filter the commits by the user or date. You can also click the Highlight non-picked commits button non_picked_commits to grey out the commits that have already been applied to the current branch.

  4. Select the required commit. Use the information in the Commit Details area if necessary.
  5. Click the Cherry-pick button cherryPickButton.png on the toolbar. PyCharm will display the Commit Changes dialog with the automatically generated commit message.
  6. If you want to review the changes or even modify the code before committing it to the target branch, you can do so in the difference viewer available from this dialog.
  7. When done, click Commit to cherry-pick the selected changes.

Note that if you click Cancel in the Commit Changes dialog, a separate changelist will be created with the selected changes that you can see in the Local Changes tab. You can review these changes and commit them later if necessary.

See Also

Last modified: 20 April 2016