Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to fetch a pull request for testing

I have been having trouble grabbing a pull request. Here is my command line attempt at the pull request code:

$ git fetch upstream pull/3/head:testbranch
Password for 'http://[email protected]':
fatal: Couldn't find remote ref pull/3/head
Unexpected end of command stream

We are using an origin repo and an upstream repo.

Pull requests go to upstream and origin is just under my name, I would like to pull down a request (#3) for review. However any time I try to grab a pull it gives me the same error even if I change from upstream to origin.

What would be causing this issue? After I grab the code I would like to put it in a branch and basically take over work on it (a hand off) so I don't need access to the person's repo that made the pull request, just the content, and I am set up as an approver for the pull request itself already

like image 802
Mike F Avatar asked Nov 19 '15 21:11

Mike F


People also ask

How do I retrieve a pull request?

Restoring a deleted branchUnder your repository name, click Pull requests. Click Closed to see a list of closed pull requests. In the list of pull requests, click the pull request that's associated with the branch that you want to restore. Near the bottom of the pull request, click Restore branch.

How do I find a specific pull request on GitHub?

On GitHub.com, navigate to the main page of the repository. In the "Branch" menu, choose the branch that contains your commits. Above the list of files, click Pull request.


1 Answers

Looking at the output it seems that either the PR is closed or the PR does not exist.

NOTE: Please commit your code before doing this as if you might have updated the code which will not be present anywhere then you might be in trouble.

The ideal way to test a PR is this way:

git fetch upstream pull/{PR-NUMBER}/head:test-branch-name
git checkout master
git merge test-branch-name

NOTE: If you find out that the code was bad and want to trace back to the previous commit then use this command:

git reset --hard HEAD@{1}

Hope it helps!

like image 101
Pujan Mehta Avatar answered Sep 29 '22 20:09

Pujan Mehta