timpone
timpone

Reputation: 19969

is it possible to clone a repository that is a pull request rather than managing as a separate branch

I have a dev who did some work and he submitted a pull request to me. Is there a way I can clone a copy of this branch? I know I can run git pull but I'd rather clone from his results (if this is possible) just to make a quick build in case there is something wrong. If I'm totally thinking about this wrong, let me know.

The branch url is like this:

https://github.com/my-name/project-name/tree/his-branch

But if I do

git clone https://github.com/my-name/project-name/tree/his-branch

I get

Cloning into his-branch...
fatal:
https://github.com/my-name/project-name/tree/his-branch/info/refs not found: did you run git update-server-info on the server?

Why am I getting and how would I just get a copy of what changes he made?

thx in advance

edit #1

I tried this but got this error:

Wed Dec 05$ git clone --branch his-branch https://github.com/my-name/project-name.git
fatal: destination path 'project-name' already exists and is not an empty directory.
Wed Dec 05$

Upvotes: 0

Views: 75

Answers (1)

Danica
Danica

Reputation: 28846

To clone a branch from a repo, you do

git clone --branch his-branch https://github.com/my-name/project-name.git

The /tree/his-branch part is just the github URL for looking at a particular branch. Instead, you need to point git to the repo and then tell it which branch with --branch or -b.

Also: you should probably be pulling from his copy of the repo, not yours. Unless you're both working on the same source repo and he's just requesting you to merge it into master instead of him, that's presumably something like https://github.com/his-name/project-name.git....

Upvotes: 1

Related Questions