1

How can I use cherry-pick to get a commit from another branch, let git detect which files had change and then merge it manually (like with mergetool)? Is it possible?

Hamlett
  • 403
  • 6
  • 22
  • Use no-merge flag maybe? `git cherry-pick -n `. See http://stackoverflow.com/questions/20837080/git-merge-no-commit-vs-git-cherry-pick-no-commit – Kleskowy Mar 12 '15 at 17:53
  • Sorry @Kleskowy but there's no no-merge flag, probably you meant no-commit but is not what I'm looking for – Hamlett Mar 12 '15 at 18:02
  • Cherry-picking effectively runs `git diff ^` to obtain the changes from that commit, then applies those changes (a la `git apply` or `git am`) to the current work-tree. If the apply step fails, it actually *does* do a full 3-way merge already. So it's not really clear to me what you want that cherry-pick is not already doing, but you can always run that same diff manually and go from there. – torek Mar 12 '15 at 18:15
  • @torek with git diff I'll get the difference from the and until the last shared node. What I need to know is only what lines had changed in the commit1 regarding to commit2 (only in the files affected by commit1) and then decide if this lines are right or not to apply it. – Hamlett Mar 12 '15 at 18:40
  • What do you mean by "until the last shared node"? Diff only diffs the particular two trees you tell it. (And, I wrote that backwards, you want `git diff X^ X` for some SHA-1 or other commit identifier `X`.) – torek Mar 12 '15 at 18:43
  • It wasn't the better expression, I wanted to mean that the diff is going to show all the differences from all the files and I just need the differences of the files affected for the commit that I want to cherry-pick – Hamlett Mar 12 '15 at 19:11
  • Ah, in that case, you can either run the full diff and trim it down, or diff just the files you care about: `git diff X^ X -- path1 path2 ... pathn`. – torek Mar 12 '15 at 20:47

0 Answers0