debian-mirror-gitlab/doc/topics/git/cherry_picking.md
2021-09-04 01:27:46 +05:30

1.1 KiB

stage group info comments
Create Source Code To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments false

Cherry pick (FREE)

Given an existing commit on one branch, apply the change to another branch.

This can be useful for backporting bug fixes to previous release branches. Make the commit on the default branch, and then cherry pick it into the release branch.

Sample workflow

  1. Check out a new stable branch from the default branch:

    git checkout master
    git checkout -b stable
    
  2. Change back to the default branch:

    git checkout master
    
  3. Make any required changes, then commit the changes:

    git add changed_file.rb
    git commit -m 'Fix bugs in changed_file.rb'
    
  4. Review the commit log and copy the SHA of the latest commit:

    git log
    
  5. Check out the stable branch:

    git checkout stable
    
  6. Cherry pick the commit by using the SHA copied previously:

    git cherry-pick <commit SHA>