Cherry-pick a Commit

Cherry-picking is taking a single commit out of one branch and applying it as a new commit to another. It’s helpful when you need the change from just one commit but don’t want to bring in the rest of the branch. For example, if a commit was accidentally made to the wrong branch, you can switch to the correct one and cherry-pick it to move it where it belongs.

You can cherry-pick commits from the Git page (accessed from VB Studio's left navigator), or while making changes in a workspace in the Designer.

For example, in the Designer, you can cherry-pick commits from a remote branch to your working branch for either an extension or visual application.

Here's how to cherry-pick a commit from the Git page:

  1. In the left navigator, click Git Git
  2. From the Repositories drop-down list, select the Git repository.
  3. On the right side of the page, click Logs.
  4. Click the History Graph Graph icon toggle button and then enter the branch name in the text box to the right of the toggle button, or select from the drop-down list.
  5. In the history graph, find the commit you want to pick and click its link.


    Description of cherrypick_historygraph_pickcomment.png follows
    Description of the illustration cherrypick_historygraph_pickcomment.png

    You’ll see the Compare view with the commit you picked and the changes at the file level.

    The ID on the left (02b0e...) shows the file as it is in your current branch, and the ID on the right (c9071...) is the commit from the other branch that you're cherry-picking.


    Description of cherrypick_compareview.png follows
    Description of the illustration cherrypick_compareview.png

  6. Click the Actions Actions menu menu and select Cherry Pick....

    You'll see the Cherry-pick commit dialog box.


    Description of cherrypick_empty_pickonto.png follows
    Description of the illustration cherrypick_empty_pickonto.png

  7. To pick the target branch where the commit will be created, use the Pick onto drop-down menu. To verify whether the change you want to make is possible or not, look at what message you get:
    • If you see the message, "The target branch already contains changes", select a different target branch. The branch you selected already has the change.
    • If you see the message, "There are conflicts and thus the commit can't be cherry-picked", you can't apply the commit because the interface doesn't provide a way to resolve the conflict. Click Cancel.
    • If you see the message, "Target branch requires review",
      1. Select Start a new merge request with the changes.


        Description of cherrypick_pickonto_branch.png follows
        Description of the illustration cherrypick_pickonto_branch.png

        In Review Branch Name, you'll see the name of the new review branch automatically created for you.

      2. Click OK to go to the New Merge Request wizard.


        Description of cherrypick_newmergerequest.png follows
        Description of the illustration cherrypick_newmergerequest.png

      3. The fields on the Branch page are already populated, so you just need to click Next to go to the Reviewers page.
      4. Select your reviewers.

        Go to the next step (Details), or if you prefer, click Next twice to jump straight to the Description page, where you can add a summary (and a description).

      5. Click Create to finish creating the merge request.

        See Create a Merge Request.

Once the commit has been successfully applied to the target branch, you can return to the Git page, select the Logs view and, in the history graph, examine the results.

Use the Git Command Line as an Alternative to the VB Studio Git User Interface

If you prefer, you can use the Git command line instead of VB Studio’s Git user interface to cherry-pick a commit from one branch and add it to another.

The git cherry-pick command is pretty simple:
git cherry-pick <commit-ID>
Where <commit-ID> is the reference to the commit you want to apply.

To find the commit reference, you'll need to use the git log. There are a few options you can use to format and filter the results For example, use --graph to draws an ASCII graph that represents the commit history's branch structure. This often used with --oneline (shows each commit on a single line) and --decorate (shows references like branches and tags for each commit).

You can also use the Git command line to create a merge request.