Skip to content

Instantly share code, notes, and snippets.

@jarnheimer
Last active October 4, 2024 14:04
Show Gist options
  • Save jarnheimer/41d4b4afaeb2b2f6b541f84ca40e2591 to your computer and use it in GitHub Desktop.
Save jarnheimer/41d4b4afaeb2b2f6b541f84ca40e2591 to your computer and use it in GitHub Desktop.
Guide on how to export a pull request to a file

Export pull request

GitHub

Save a pull request as a pr.diff

curl -H "Accept: application/vnd.github.v3.diff" -u [username]:[personal_access_token] https://api.github.com/repos/[organization]/[repo]/pulls/[pull id] > pr.diff 

Replace

  • username your Github username
  • personal_access_token can be generated under https://github.com/settings/tokens
  • organization name of the organization
  • repo name of the repository
  • pull id ID of the pull request

Example

To export this https://github.com/proxify-ab/proxify-app-platforms/pull/4746

the following code is used

curl -H "Accept: application/vnd.github.v3.diff" -u viktorjarnheimer:SECRET https://api.github.com/repos/proxify-ab/proxify-app-platforms/pulls/4746 > pr.diff

Bitbucket

Save a pull request as a pr.diff

curl -u [username]:[app_password] https://bitbucket.org/api/2.0/repositories/[workspace]/[repo_slug]/pullrequests/[pull id]/diff > pr.diff

Replace:

  • username with your Bitbucket username
  • app_password with your Bitbucket app password (which can be generated under App Passwords)
  • workspace with the workspace ID or username for the repository
  • repo_slug with the slug of the repository (the name in lowercase, with spaces replaced by hyphens)
  • pull id with the ID of the pull request

Example

To export this pull request: https://bitbucket.org/proxify-ab/proxify-app-platforms/pull-requests/4746

The following code is used:

curl -u jarnheimer:SECRET https://bitbucket.org/api/2.0/repositories/proxify-ab/proxify-app-platforms/pullrequests/4746/diff > pr.diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment