dudeguypal
dudeguypal

Reputation: 31

Git merge remote pull requests on local clone

I am trying to grade assignments submitted to a git repository in the form of pull requests. Each pull request is one student's submission. There is only one branch in this repo that holds the assignment prompt. (I don't have write access to this repo.)

How would I go about testing each of these pull requests on my local machine? I have tried something like the following:

gives me the following error:

remote: Counting objects: 61, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 61 (delta 21), reused 20 (delta 20), pack-reused 37
Unpacking objects: 100% (61/61), done.
From https://github.com/repo-name
! [rejected]
refs/pull/1/head -> [student-alias] (non-fast-forward)

Upvotes: 2

Views: 2890

Answers (1)

LinFelix
LinFelix

Reputation: 1072

If you just want to test each branch than

git fetch origin [student-alias]
git checkout origin/[student-alias]

would allow you to set your working directory into the current state of each branch [student-alias]

If you want to checkout the state of the pull request (which usually on github does not differ from the most recent version of the branch it is coming from unless merged), then I suggest following the tutorial you linked (without the not mentioned --update-head-ok and go with

git fetch origin pull/[pull-request-id]/head:[student-alias]
git checkout [student-alias]

The difference between these two is, that the former works on a branch and the latter on a pull request (which is a github feature).

Upvotes: 2

Related Questions