chink
chink

Reputation: 1653

how to merge only the diff in a PR to a different branch?

I have a branch called release/app1/sprint1 from which I created my local branch feature/app1/sprint1/task1, I was constantly merging and pulling the changes from release/app1/sprint1 to my local branch along with my own commits. There is a different branch called release/app2/sprint1. Now my lead is saying whatever changes I added as part of feature/app1/sprint1/task1 those should be merged with release/app2/sprint1 and not release/app1/sprint1. Is to possible to merge only the diff of feature/app1/sprint1/task1 and release/app1/sprint1 to a newly created branch from release/app2/sprint1 ?

One way I have in mind is to manually add all the changes by copy paste to a new branch created from release/app2/sprint1 and raise a pull request.

Upvotes: 0

Views: 350

Answers (1)

Mahdi Aryayi
Mahdi Aryayi

Reputation: 1120

you can create a patch file from the diff and apply it to the new branch

git diff <branch1> <branch2> > diff.patch
git checkout <branch3>
git apply diff.patch

which obviously, <branch1>, <branch2> and <branch3> are your specific branch names.

Upvotes: 2

Related Questions