I've got two branches in git, master/ and 1.7/. I backport some fixes from master/ into 1.7/, using cherry-pick. (I'm not using merge because I only want some of the changes.):
$ git checkout 1.7
$ git cherry-pick -x <initial commit SHA>..<master change 2 SHA>
Then later on, I merge 1.7/ back to master/, because I want all changes that have gone into 1.7/ (except for the cherry-picks themeselves) to be merged back to the mainline:
$ git checkout master
$ git merge 1.7
My problem is that this re-commits the cherry-picks (originally from master/) into master/ again:
$ git log --oneline
8ecfe22 Merge branch '1.7'
fe3a60d master change 2 (cherry picked from commit f5cca9296e45d5965a552c45551157ba
9c25f53 master change 1 (cherry picked from commit 8fae2a68a356f5b89faa8629b9a23b23
f5cca92 master change 2
8fae2a6 master change 1
ffa10bf initial commit
In my real repository it even caused merge conflicts.
So my question is, can I avoid this (and if so, how)?
The full list of commands to reproduce this behavior:
$ git init
<create Dialog.js file>
$ git add Dialog.js
$ git commit -am "initial commit"
$ git branch 1.7
<edit Dialog.js file>
$ git commit -am "master change 1"
<edit Dialog.js file>
$ git commit -am "master change 2"
$ git log
$ git checkout 1.7
$ git cherry-pick -x <initial commit SHA>..<master change 2 SHA>
$ git checkout master
$ git merge 1.7
$ git log