SunnyMonster
SunnyMonster

Reputation: 550

How to merge a branch of a fork to a branch of another fork in github?

I know how to compare between forks in Github. However I am running into a problem.

I am trying to merge the unblock_events_windows_move_resize branch of this fork of glfw into the resize-move-fix branch of my fork.

I am not able to find that fork when I am making a new pull request, as seen below: enter image description here So what is the problem here?

Upvotes: 1

Views: 1406

Answers (1)

ElderFuthark
ElderFuthark

Reputation: 631

I know if you are the one who created the original repo and then someone forked it, only they can create a pull request to upstream through the UI. But in terms of opening a PR from one fork to another fork via the web UI, I don't think it's possible (at least at the time of this post).

However, you can easily accomplish what you want via the git CLI tool, assuming both forks are public.

Option 1: git pull

git pull can accept a git URL as an argument. What this means, is you can effectively do git pull <GIT URL> <branch name> to merge any public fork into your own. So in this case you would do git pull https://github.com/mmozeiko/glfw.git unblock_events_windows_move_resize. This is good for one-time or occasional merges. A more permeant option would be to set up a second remote.

Option 2: Setting up a second remote

You can add numerous remotes to your local repository. By default, projects' cloned from GitHub will have a remote called origin which points to your repository (via the Git URL). You can add a new remote to any repository using git remote add <short form> <Git URL>. In your case, this might be something like git remote add mmozeiko https://github.com/mmozeiko/glfw.git. Now you can checkout your branch via git checkout and then do git pull mmozeiko unblock_events_windows_move_resize.

Upvotes: 3

Related Questions