Kowshhal
Kowshhal

Reputation: 291

git - bring changes of one branch to another with diff parents

I have branch A branched out from a release branch. I made some commits on branch A. Now I want to bring these commits (only these commits) to another branch based out of master.

master and this branch also have different commits made by others. How is it possible to just bring my commits to this new branch? If I merge the branches those changes will also come in right? Can someone help me how i can achieve this?

Upvotes: 1

Views: 43

Answers (1)

VonC
VonC

Reputation: 1329082

That would be a git rebase --onto:

git rebase --onto anotherBranch $(git merge-base release A) A

# or
git switch A
git rebase --onto anotherBranch $(git merge-base --fork-point release) A

That will move any commit made after merge-base release A and A to anotherBranch.
(Using merge-base --fork-point release is also possible)

Upvotes: 2

Related Questions