How can I git clone the PR which haven't been merged by the author in github
? Tried to fork a repo but the pr is gone.
Asked
Active
Viewed 2,325 times
2

Charles Jr.
- 117
- 5
-
`git fetch upstream branch-of-the-pr`? – JB Nizet Apr 05 '19 at 10:58
-
I don't own the repo – Charles Jr. Apr 05 '19 at 11:03
-
Yes, that's why I used `upstream`. `upstream` is the traditional name of the remote for the original repo of your fork. – JB Nizet Apr 05 '19 at 11:04
-
@CharlesJr., do you have the original repo set up as a remote? See https://stackoverflow.com/q/7244321/354577 – ChrisGPT was on strike Apr 05 '19 at 11:38
-
Possible duplicate of [How to pull a pull request quickly locally](https://stackoverflow.com/questions/6389127/how-to-pull-a-pull-request-quickly-locally) – phd Apr 05 '19 at 14:21
-
https://stackoverflow.com/search?q=%5Bgithub%5D+pull+request+locally – phd Apr 05 '19 at 14:21
2 Answers
2
clone
then fetch
that PR to a local branch. For example:
git clone https://github.com/mimblewimble/grin
git fetch origin pull/2932/head:pr2932
git checkout pr2392
Note:
- replace
https://github.com/mimblewimble/grin
with your source repo - replace
2932
with your source Pull Request number - replace
pr2932
with your desired branch name
I was looking for a single command to clone a single branch of a PR, but it seems not exist (please let me if somebody know that trick).

gary
- 1,569
- 3
- 20
- 30
1
By "clone the PR", I assume you mean: "having my local clone of the project at the state of a given PR".
You clone a repository, not a Pull Request. Git itself has no notion of Pull Request. However, the Pull Request is probably associated with a branch, so you can do:
git clone url/of/your/repo destinationDirectory
cd destinationDirectory
git checkout branchOfThePR
If you already have a clone, then, as @JB Nizet said, you need to fetch the new branches:
git fetch remoteName
Then you can check the branch out:
git checkout branchOfThePR

padawin
- 4,230
- 15
- 19