debian-mirror-gitlab/doc/university/training/topics/cherry_picking.md

37 lines
1,004 B
Markdown
Raw Normal View History

2018-03-17 18:26:18 +05:30
---
2021-01-29 00:20:46 +05:30
stage: none
group: unassigned
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
2018-03-17 18:26:18 +05:30
comments: false
---
2017-08-17 22:00:37 +05:30
# Cherry Pick
- Given an existing commit on one branch, apply the change to another branch
- Useful for backporting bug fixes to previous release branches
- Make the commit on the master branch and pick in to stable
2019-10-12 21:52:04 +05:30
## Cherry Pick sample workflow
2017-08-17 22:00:37 +05:30
1. Check out a new 'stable' branch from 'master'
1. Change back to 'master'
1. Edit '`cherry_pick.rb`' and commit the changes.
1. Check commit log to get the commit SHA
1. Check out the 'stable' branch
1. Cherry pick the commit using the SHA obtained earlier
2020-03-13 15:44:24 +05:30
```shell
2017-08-17 22:00:37 +05:30
git checkout master
git checkout -b stable
git checkout master
# Edit `cherry_pick.rb`
git add cherry_pick.rb
git commit -m 'Fix bugs in cherry_pick.rb'
git log
# Copy commit SHA
git checkout stable
git cherry-pick <commit SHA>
```