I have a private repo on github, belonging to an org. For a given pull request, there's a url to a diff file like this:
https://github.com/<ORG>/<REPO>/pull/<PR_NUMBER>.diff
But the repo is private, so how can I download this file with curl? I generated a "personal access token", but am a bit lost as to how to use it.
I tried this:
curl -H 'Authorization: token <TOKEN>' -H 'Accept: application/vnd.github.v3.raw' -O -L "https://github.com/<ORG>/<REPO>/pull/<PR_NUMBER>.diff"
But all that sent back was "Not Found".
On GitHub.com, navigate to the main page of the repository. Click the file that you want to view. In the upper-right corner of the file view, click Raw.
You can use the pull request url from api.github.com with different accept content type. e.g.
curl -H 'Authorization: token mytoken' -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/orgname/repo/pulls/1234
Notice: Please remove ".diff" suffix from the url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With