0

I have 2 master branches for 2 different versions of my application. I want to make fixes for both them using a pull request, but I want to include in it only the last commit. One of those branches has a few (~5) commits that the other branch doesn't have, because only one of them is supported now.

I using Atlassian's Stash.

SQB
  • 3,926
  • 2
  • 28
  • 49
El Szarry
  • 13
  • 3

1 Answers1

0

Make a new branch from the master you are merging into. Cherry pick the commit you want to merge into that branch. Then open a pull request for that branch.

Alternately, rather than a full-blown pull request, you could just cherry-pick the commit from one into the other.

Start here, where M1 is the branch you want to merge into, and e is the commit with the fix you want in both branches:

-M1

-M2-a-b-c-d-e

Simplest is just to cherry-pick the fix:

$ git checkout M1
$ git cherry-pick e

That gets you this:

-M1-e'

-M2-a-b-c-d-e

If you must do a pull request, try this:

$ git checkout M1
$ git checkout -b M3
$ git cherry-pick e

That will get you this:

-M1
  \
   M3-e'

-M2-a-b-c-d-e

...and once you issue the pull request and it gets merged - most likely a fast-forward merge - you'll be back here:

-M1-e''

-M2-a-b-c-d-e
pjmorse
  • 9,204
  • 9
  • 54
  • 124