Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge pull request into different branch

I'm maintaining a legacy GitHub repo now and there is a lot of abandoned PR into old branches. For example, I work in the v3.5 branch now, and PRs are for 3.3 and older.

How can I effectively merge them into my new branch if they target older ones?

In case it's important, I'm sure there will be no conflicts.

I found some old questions about similar things, but I can't find any info on how to do it via GitHub. Is there still no functionality on that? Do I have to manually do it via git?

like image 600
s1ddok Avatar asked Mar 06 '16 18:03

s1ddok


People also ask

How do I merge a pull request to another branch?

To do that go to your repository's home page, click on branches, and change the default branch from master into something else, in my case "dev". After that, whenever someone creates a pull request the merge button will automatically merge the request into "dev" rather than master.

How do I raise a pull request from one branch to another in git?

Create a pull request Go to the Branches tab on a Git repository page. Click Create. Select the source branch which is wanted to be merged. Select the target branch to which you want the changes to be merged.

Can I merge a branch into another branch?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.


2 Answers

On the github.com pull-request page there is a link to "command line instructions". If you like to do it manually the steps are:

  • Create a new merge-branch off the PR target branch. Checkout the merge-branch. Pull the PRs by hashes or head refs into the merge-branch.
  • Merge the merge-branch into your new target branch by pull, merge, or cherry-pick.

A little bit more searching found this page about renaming branch on github website. It suggests:

  • Set default branch to your old-target branch. Create a branch off your old-target branch with a different name.
  • Merge the PRs to the old-target branch. Rename the old-target branch to something different.
  • Rename your other new branch to the old-target branch name.
like image 127
minghua Avatar answered Oct 23 '22 05:10

minghua


All of the pull requests are saved here

pull/ID/head

You can check out s pull request locally by

git fetch REMOTENAME pull/ID/head:BRANCHNAME
git checkout BRANCHNAME 

if you want all pulls you can add to the fetch ref

This is a read only address. Is you can't push back to it up update the pull request

Remote name is the local git name for the remote

These are shown by git remote -v

like image 41
exussum Avatar answered Oct 23 '22 03:10

exussum