[jbosstools-dev] Help: Applying PRs to two branches

phantomjinx p.g.richardson at phantomjinx.co.uk
Wed Jul 24 06:03:43 EDT 2013


On 07/24/2013 09:16 AM, Michelle Murray wrote:
> Can anyone instruct me how to apply a PR to two branches?
> 
> So I made a PR with some changes. I applied that to master branch. All good.
> 
> But I want to also apply the changes in the PR to 4.1.x. But master and 4.1.x are out of sync. When
> I try to apply my PR, github wants to apply all of the previous changes to make the branches the
> same before applying my changes. I only want to apply my changes.
> 
> If you can follow what I'm saying, can you advice what do I need to do? (Or where I've gone wrong!)
> 
> Thanks,
> Michelle

Hi Michelle,

Depending on the number of the commits the PR represents, you could cherry-pick or rebase the PR
commits from master onto your 4.1.x branch in your local git repository.

If there is only a couple of commits in the PR, eg.

<master branch> -- A -- B

<4.1.x branch>

git checkout 4.1.x
git cherry-pick A
git cherry-pick B

will result in:

master -- A -- B

4.1.x -- A' -- B'


Should there be many commits in the PR then use git rebase, eg.

git rebase --onto 4.1.x A master

This will essentially take all the commits from A -> the head of master and replay them on top of
4.1.x. Its a more automated process than cherry-picking but will end with the same result. If you
run into problems then simply 'git rebase --abort' to reset the branch.

Once you have your local repo correct, simply push the new 4.1.x branch to github.

Regards

PGR

-- 
Paul Richardson

  * p.g.richardson at phantomjinx.co.uk
  * p.g.richardson at redhat.com
  * pgrichardson at linux.com

"I know exactly who reads the papers ...

  * The Daily Mirror is read by people who think they run the country.
  * The Guardian is read by people who think they ought to run the country.
  * The Times is read by people who do actually run the country.
  * The Daily Mail is read by the wives of the people who run the country.
  * The Financial Times is read by the people who own the country.
  * The Morning Star is read by the people who think the country ought to be run by another country.
  * The Daily Telegraph is read by the people who think it is."

Jim Hacker, Yes Minister



More information about the jbosstools-dev mailing list