Applying Changes from a Specific Commit to Other Branches (Cherry Picking)
Suppose, you have two diverged branches,
One day, you decide to integrate changes from one specific commit in
With PhpStorm, you can cherry pick between branches right from the Changes tool window.
To cherry pick changes between two branches
Switch to the target branch that the changes will be integrated to.
It is required that your working tree is clean, that is, there should be no modifications from the
- Open the Changes tool window and switch to the Log tab.
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.
- Select the required commit. Use the information in the Commit Details area if necessary.
- Click the Cherry-pick button on the toolbar. PhpStorm will display the Commit Changes dialog with the automatically generated commit message.
- 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.
- 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.