使用curl,如何从github上的私有存储库下载.diff文件

pol*_*pia 8 curl github

我在github上有一个私人回购,属于一个组织.对于给定的pull请求,有一个像这样的diff文件的url:

https://github.com/<ORG>/<REPO>/pull/<PR_NUMBER>.diff
Run Code Online (Sandbox Code Playgroud)

但是repo是私有的,那么如何用curl下载这个文件呢?我生成了一个"个人访问令牌",但是如何使用它有点迷失.

我试过这个:

curl -H 'Authorization: token <TOKEN>' -H 'Accept: application/vnd.github.v3.raw' -O -L "https://github.com/<ORG>/<REPO>/pull/<PR_NUMBER>.diff"
Run Code Online (Sandbox Code Playgroud)

但发回的所有内容都是"未找到".

c9s*_*c9s 9

您可以使用api.github.com中具有不同接受内容类型的pull request url.例如

curl -H 'Authorization: token mytoken' -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/orgname/repo/pulls/1234
Run Code Online (Sandbox Code Playgroud)

注意:请从网址中删除".diff"后缀.