2

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.

Charles Jr.
  • 117
  • 5

2 Answers2

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:

  1. replace https://github.com/mimblewimble/grin with your source repo
  2. replace 2932 with your source Pull Request number
  3. 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