I thought I understood cherry-picking, but can't get it to work in 
practice. Can somebody please explain what I'm missing?

*Setup*

   1. Start with a plain text file in *master* with two rows in it (one 
   commit per row):
      1. L1
      2. L2
   2. Create a branch (*workbranch*) and check it out
   3. Modify the file as follows (one commit per row)
      1. Change "L1" to "Line1" and "L2" to "Line2"
      2. Add "Line3"
   4. Checkout *master*
   5. Modify the file as follows (one commit per row)
      1. L3
      2. L4
   
At this point my file according to *master* is:

L1
L2
L3
L4


My file according to *workbranch* is:

Line1
Line2
Line3


My goal: to cherry-pick the "L3" commit from *master* to *workbranch*, so 
that my file according to *workbranch *would end up being:

Line1
Line2
Line3
L3


I thought I could just issue the command git cherry-pick master~1, but git 
reports a conflict, which includes *all* of my *master* commits:

<https://lh4.googleusercontent.com/-5A8cBSUD7Dg/U_5PvsLrhnI/AAAAAAAAAUk/VuH2PRlBfAQ/s1600/conflict.jpg>

I thought cherry-pick would only include the delta for L3? So how do I do 
this?

Please understand this is an exercise to understand *cherry-pick*. There 
may be other ways to do this, but for now I want to focus on cherry-picking.

*Git commands to setup*

Here are the git commands I use to create the setup:

echo L1 > test.txt
git add test.txt
git commit -m "L1"
echo L2 >> test.txt
git stage -u
git commit -m "L2"
git branch workbranch
git checkout workbranch
echo Line1 > test.txt
echo Line2 >> test.txt
git stage -u
git commit -m "Lines1 and 2"
echo Line3 >> test.txt
git stage -u
git commit -m "Line3"
git checkout master
echo L3 >> test.txt
git stage -u
git commit -m "L3"
echo L4 >> test.txt
git stage -u
git commit -m "L4"
git checkout workbranch

*NOTE: I'm using git on Windows 7*

Thanks!
Brian

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to