Return to site

Cherry-pick separate commits with IntelliJ

· github,intellij

Sometimes you only need to apply a single commit to a different branch instead of rebasing or merging an entire branch. This may be useful, for example, if you are working in a feature branch and want to integrate a hotfix from master that was committed after the two branches have diverged. Or you may want to backport a fix to a previous release branch. You can do so by using the Cherry-pick action.

The status of a cherry pick operation is displayed in the status bar. You can always abort an ongoing cherry-pick by selecting Abort Cherry-Pick in the Git Branches popup.

broken image


Apply a commit to another branch

  1. In the Branches popup (main menu Git | Branches), select the target branch that you want to integrate the changes to and choose Checkout from the popup menu to switch to that branch.
  2. Open the Git tool window Alt+9 and switch to the Log tab.
  3. Locate the commit containing the changes you want to cherry pick.
  4. Select the required commit. Use the information in the Commit Details area to make sure these are the changes you want to transfer to another branch.
  5. Click Cherry-pick on the toolbar. AppCode will apply and commit changes to the target branch.
  6. If the cherry-pick failed with conflicts, the selected changes will appear in the Changes area that you can see in the Local Changes view. You can review these changes and commit them later if necessary.
  7. Push the changes to the target branch.