Re: [git-users] Understanding Cherry-Pick
The problem I see with your interpretation of what went wrong (which I simply assume to know), is that you attribute the resulting conflict markers to git-cherry-pick not working as expected. I suspect that git-cherry-pick just doesn't know where to put the patch and defaults to git-merge looking for common ancestors in order to find out - which he does. However, git-merge is still not able to merge without a conflict. I don't think any of git's merge strategies will do what you hope for in this example (because I tried them), but there are ways to favor different behavior (merge strategies), for example favor the other guy (the commit you're picking), such as the following example shows: git cherry-pick b931360 --strategy=recursive -Xtheirs Please note that while I did test your example, I am not a git developer (so I have not seen the actual implementation) and I might be wrong about what actually happened. A second - more educated - opinion on this would be great -- 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.
[git-users] Understanding Cherry-Pick
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/AUk/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.
Re: [git-users] Understanding Cherry-Pick
Hello Brian, the patch you are getting is actually the difference between L3 and workbranch (Line3). What you are facing is a conflict resolution: you have different modifications for the same file; in this case, both master~1 and workbranch added lines to the test.txt file, and now you have to decide which version you want to keep (which, apparently, can be both). The lines between and === are your local changes, and the lines between === and are the remote changes (e.g. the changes you are cherry picking). Although you are trying to learn about cherry picking, I would suggest to go through merging and conflict resolution first. These may help you understand your current situation, as cherry-pick is very similar to merging. Best, Gergely On 28 Aug 2014 00:16, Brian Wall briandw...@gmail.com wrote: 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/AUk/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. -- 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.