3. Move a pull request to a different branch: Revision

Last updated by Steve Clay

It's often necessary to move a pull request to a different branch.

Let's say you have a branch 1234 and you need to move it from master to 1.11. I have two separate Elgg installed for these branches in ~/www/elgg-master and ~/www/elgg-1.11/.

There's probably a git rebase solution for this, but I find it easy enough to cherry-pick the commits onto a new branch. First I do a git log and copy the SHAs of the commits I want to apply in reverse order:

cd ~/www/elgg-1.11/
git remote add local_master ~/www/elgg-master
git fetch local_master

Now my 1.11 repository has all the commits in my master repository. I just recreate the branch on 1.11 and cherry-pick over:

git checkout 1.11  #just to make sure
git checkout -b 111_1234
git cherry-pick SHA  #SHA is the commit SHA I'm copying
git push -u fork 111_1234  #fork is my forked Elgg repo on GitHub

Now I go to https://github.com/Elgg/Elgg and GitHub helpfully gives me the option to create a new pull request on my shiny new 111_1234 branch. I then go into the old pull request and close it after linking to the new one.

Feedback and Planning

Feedback and Planning

Discussions about the past, present, and future of Elgg and this community site.