Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fork github repository and its pull requests

I'm looking for a way to recover pull requests from a forked repository. Is it possible?

like image 962
Joel AZEMAR Avatar asked May 27 '26 05:05

Joel AZEMAR


1 Answers

When one fork a repository, GitHub only forks the code, not the pull requests.

However, you can retrieve the pull requests from the upstream repository by leveraging the GitHub Pull Request API.

  • syntax GET /repos/:user/:repo/pulls
  • sample: https://api.github.com/repos/libgit2/libgit2/pulls

By default, only the PR which are currently opened are listed. You can access the closed ones by passing an optional state parameter.

  • sample: https://api.github.com/repos/libgit2/libgit2/pulls?state=closed

Note: This will allow you to retrieve the metatdata of the pull requests of any repository (forked or not).

Alternative (by hand) way

$ mkdir libgit2
$ git clone http://github.com/libgit2/libgit2
$ git fetch origin +refs/pull/*:refs/remotes/pull/*

This will retrieve every pull request (opened and closed) from the GitHub hosted repository and create a branch per pull request in you local repository.

Warning: this is an undocumented GitHub feature and might stop working without notice.

like image 186
nulltoken Avatar answered May 30 '26 03:05

nulltoken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!