Daniel Armstrong Daniel Armstrong - 2 months ago 11
Git Question

How can I apply a pull request from the main project branch to my fork using the github UI or via command line?

I wish to apply this pull request

https://github.com/MonoGame/MonoGame/pull/5114

to https://github.com/Danthekilla/MonoGame

There doesn't seem to be a way to do this at first glance, is there a way to do it with TortoiseGit?

Perhaps some command like this?:

git merge https://github.com/Danthekilla/MonoGame https://github.com/MonoGame/MonoGame/pull/5114

Answer

You must specify the repository and branch to perform the pull request on when you originally create said pull request. AFAIK, there isn't any way to edit an existing pull request to do this.

From the GitHub web UI

  1. Go to the repo you want to pull from (https://github.com/Jjagg/MonoGame)
  2. Select the branch that you want to pull (getbackbufferdata)
  3. Click on New Pull Request
  4. If the branch to pull onto does not appear at the top of the pull request creation page, then click on "compare across forks"
  5. On the left, select the base repository and base branch which you want to pull onto
  6. Click View Pull Request

From the command line

$ git checkout develop
$ git pull https://github.com/Jjagg/MonoGame/getbackbufferdata

(Caveat Emptor: I'm not 100% sure about the URL in the above command.)

If you don't want to merge directly to the develop branch, you can create a temporary branch to merge to. For example

$ git checkout -b jjagg/getbackbufferdata develop
$ git pull https://github.com/Jjagg/MonoGame/getbackbufferdata

If you often need to pull from a GitHub repo which belongs to a fellow contributor, you can create a remote for said repo

$ git remote add jjagg https://github.com/Jjagg/MonoGame

Now you can pull directly from this remote

$ git checkout -b jjagg/getbackbufferdata develop
$ git pull jjagg getbackbufferdata

All of this is a little easier with command-line completion. Once the remote is added, you can type git pull j then push Tab to complete the remote name. Then after git pull jjagg g Tab again will complete the branch name. If two branches start with g, then a double Tab will show all possible choices.

Comments