Attempting to Apply Cherry-Pick
Learn why a cherry-pick might not work and about the “three-way merge.”
We'll cover the following
A simple branched repository
This should be fairly routine by now. You’re going to set up a Git repository with two branches and some simple changes in them. Once that’s done, you’re going to try to cherry-pick a change from the abranch
branch and apply it to the master
branch.
1 mkdir lgthw_patch_and_apply
2 cd lgthw_patch_and_apply
3 git init
4 touch afile
5 git add afile
6 git commit -m 'afile added'
7 echo First change, on master >> afile
8 git commit -am 'First change, on master added'
9 git branch abranch
10 echo Second change, on master >> afile
11 git commit -am 'Second change, on master added'
12 git checkout abranch
13 echo First change, on abranch >> afile
14 git commit -am 'First change, on abranch added'
15 echo Second change, on abranch >> afile
16 echo New file, on abranch >> newfile
17 git add newfile
18 git commit -am 'Second change, on abranch added'
19 git tag abranchtag
20 git checkout master
Get hands-on with 1400+ tech skills courses.