Commit 6ad5c46a authored by Craig Norris's avatar Craig Norris Committed by Marcel Amirault

Move cherry pick file

Move existing cherry pick file to new location.
parent fe0a1721
---
stage: Create
group: Source Code
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/#assignments
comments: false
---
# Cherry Pick
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:
```shell
git checkout master
git checkout -b stable
```
1. Change back to the default branch:
```shell
git checkout master
```
1. Make any required changes, then commit the changes:
```shell
git add changed_file.rb
git commit -m 'Fix bugs in changed_file.rb'
```
1. Review the commit log and copy the SHA of the latest commit:
```shell
git log
```
1. Check out the `stable` branch:
```shell
git checkout stable
```
1. Cherry pick the commit by using the SHA copied previously:
```shell
git cherry-pick <commit SHA>
```
---
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/#assignments
comments: false
redirect_to: '../../../topics/git/cherry_picking.md'
---
# Cherry Pick
This document was moved to [another location](../../../topics/git/cherry_picking.md).
- 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
## Cherry Pick sample workflow
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
```shell
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>
```
<!-- This redirect file can be deleted after <2021-06-01>. -->
<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page -->
......@@ -4,5 +4,5 @@ redirect_to: '../../../topics/git/tags.md'
This document was moved to [another location](../../../topics/git/tags.md).
<!-- This redirect file can be deleted after <YYYY-MM-DD>. -->
<!-- This redirect file can be deleted after <2021-06-01>. -->
<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page -->
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment