从 Private Repo 下载 Git 存档 tarball 时遇到问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10046027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:43:28  来源:igfitidea点击:

Having trouble downloading Git archive tarballs from Private Repo

gitgithub

提问by SJP

I need the ability to download our application at specific tags, but I am unable to find a working solution for this. Downloading tarballs based on git tag seems promising but I am unable to get it working using Curl. I have tried the following but all I get back is the source for the github 404 page.

我需要能够在特定标签处下载我们的应用程序,但我无法为此找到可行的解决方案。下载基于 git 标签的 tarball 看起来很有希望,但我无法使用 Curl 让它工作。我尝试了以下操作,但我得到的只是 github 404 页面的源代码。

curl -sL https://github.com/$ACCOUNT/$PRIVATE_REPO/tarball/0.2.0.257m?login=$MY_USER_NAME&token=$MY_TOKEN > 0.2.0.257m.tar

回答by VonC

For public repo, you have this gistlisting some examples:

对于公共回购,你有这个要点列出了一些例子:

wget --no-check-certificate https://github.com/sebastianbergmann/phpunit/tarball/3.5.5 -O ~/tmp/cake_phpunit/phpunit.tgz

For a private repo, try passing your credential information in a post directive:

对于私有存储库,请尝试在 post 指令中传递您的凭证信息:

wget --quiet --post-data="login=${login}&token=${token}" --no-check-certificate https://github.com/$ACCOUNT/$PRIVATE_REPO/tarball/0.2.0.257m

Or use a curl command as in SO question "git equivalent to svn exportor github workaround", also explained in great details in:
"A curl tutorial using GitHub's API".

或者在 SO 问题“ git 等效于svn export或 github 解决方法”中使用 curl 命令,也在:
使用 GitHub 的 API 的 curl 教程”中进行了详细解释。



The OP Steven Jpreports having made the curlcommand work:

OP史蒂芬太平绅士作出报告的curl指挥工作:

The final curl command ended up looking something like this:

最后的 curl 命令看起来像这样:

curl -sL --user "${username}:${password}" https://github.com/$account/$repo/tarball/$tag_name > tarball.tar

(in multiple lines for readability)

(多行以提高可读性)

curl -sL --user "${username}:${password}" 
  https://github.com/$account/$repo/tarball/$tag_name
  > tarball.tar

回答by tjanez

After creating an access token,

创建访问令牌后

you can use wget:

你可以使用wget

wget --output-document=<version>.tar.gz \
    https://api.github.com/repos/<owner>/<repo>/tarball/<version>?access_token=<OAUTH-TOKEN>

or curl:

curl

curl -L https://api.github.com/repos/<owner>/<repo>/tarball/<version>?access_token=<OAUTH-TOKEN> \
    > <version>.tar.gz

More information can be found in GitHub's API reference for archive links.

更多信息可以在GitHub 的存档链接 API 参考找到

回答by Gamma

Log into your Private Org on Github.com, then go here to create your token: https://github.com/settings/applications#personal-access-tokens

在 Github.com 上登录您的私人组织,然后到这里创建您的令牌:https: //github.com/settings/applications#personal-access-tokens

When trying to Curl into your Private Org, use the following:

尝试卷入您的私人组织时,请使用以下内容:

curl --header 'Authorization: token ADDACCESSTOKENHERE' \
 --header 'Accept: application/vnd.github.v3.raw' \
 --remote-name \
 --location https://api.github.com/repos/ORG/PROJECT/contents/FILE

Replace what's in CAPS with your information...

用您的信息替换 CAPS 中的内容...