无人机如何克隆存储库?

发布于 2025-01-31 12:47:41 字数 78 浏览 3 评论 0 原文

对于GitLab,如果我获得了client_id和client_secret,则如何克隆存储库,就像无人机的作用一样。有没有API或其他东西?

For gitlab, if I get the client_id and client_secret, how can I clone the repository, just like what drone does. Is there any API or something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

々眼睛长脚气 2025-02-07 12:47:41

由于 git clone 本机命令。

然后,您可以尝试使用:(

git clone https://oauth2:TOKEN@ANY_GIT_PROVIDER_DOMAIN/YOUR_PROJECT/YOUR_REPO.git

假设 client_secret 是令牌)

或:(

git clone https://client_id:TOKEN@ANY_GIT_PROVIDER_DOMAIN/YOUR_PROJECT/YOUR_REPO.git

用实际值替换client_id),


但是,这被视为不良练习,

URL '%s' uses plaintext credentials

最好缓存这些凭据:

git config --global credential.helper
xxx <= note that value

printf "host=gitlab.com\nprotocol=https\nusername=client_d\npassword=client_secret" | \
git credential-xxx store

/stackoverflow.com/a/72649714/6309"> git 和 client_secret 通过其实际值)

,然后

git clone https://client_id@ANY_GIT_PROVIDER_DOMAIN/YOUR_PROJECT/YOUR_REPO.git

在URL中不再使用令牌/秘密。

The is no "GitLab API" for cloning, since git clone native command is there for that.

You could then try and clone with:

git clone https://oauth2:TOKEN@ANY_GIT_PROVIDER_DOMAIN/YOUR_PROJECT/YOUR_REPO.git

(assuming the client_secret is the token)

Or:

git clone https://client_id:TOKEN@ANY_GIT_PROVIDER_DOMAIN/YOUR_PROJECT/YOUR_REPO.git

(replace client_id by the actual value)


However, this is considered bad practice, and Git 2.37 (Q3 2022) will display the warning:

URL '%s' uses plaintext credentials

It is better to cache those credentials:

git config --global credential.helper
xxx <= note that value

printf "host=gitlab.com\nprotocol=https\nusername=client_d\npassword=client_secret" | \
git credential-xxx store

(replace xxx, client_id and client_secret by their actual values)

And then

git clone https://client_id@ANY_GIT_PROVIDER_DOMAIN/YOUR_PROJECT/YOUR_REPO.git

No more token/secret in the URL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文