My team is working on a shared topic branch in git which I will call "topic1." I was working on a refactor of some code on a branch made off of topic1, which I will call "refactor." I have been periodically merging topic1 into refactor so I can stay up to date with changes, but have not merged refactor back into topic1 because the refactor is still in progress.
There is another topic branch, which I'll call "topic2" which was recently created off of master. What I'd like to do is merge only the changes that I've made on "refactor" to a new branch made off of topic2, which I'll call "topic2_refactor." (I.E. the changes in the commits accessible only by refactor but not by topic1.)
I know how to see these just these changes:
git log origin/refactor --not origin/topic1
So what I'd like to do is something like this - but this syntax is not correct:
git checkout topic2
git checkout -b topic2_refactor
And then this:
git merge origin/refactor --not origin/topic1
Or this:
git cherry-pick origin/refactor --not origin/topic1
(The above seems to be causing merge conflicts that aren't neccessary, due to some changes which occured on master that was later merged back into the refactor branch.)
I was hoping that there is a clean way to do this and avoid unnecessary merge conflicts that were resolved later on in the history of the "refactor" branch. Might this be possible using git rebase, git filter-branch, etc?