在脚本内部我试图用oauth令牌克隆Github存储库.
根据本教程:
https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth
我应该能够为它构建一个命令:
git clone https://<token>@github.com/owner/repo.git
Run Code Online (Sandbox Code Playgroud)
如果我使用适当的访问令牌手动尝试此操作,它仍然会要求我输入密码.
如果我在命令行上尝试它,我只是得到一个repository not found错误.
该文章来自2012年,我找不到任何API文档.所以我想知道这是否仍然有效.
hob*_*dev 48
请尝试这个。
git clone `https://oauth2:TOKEN@github.com/username/repo.git`
Run Code Online (Sandbox Code Playgroud)
例如,git clone https://oauth2:ghp_...Gnm61dm4rh@github.com/gituser/testrepo.git
Ste*_*n-v 43
我原来是一个范围问题.我当然需要完整的repo范围,因为我试图克隆一个private存储库.
遗憾的是,Github没有为这类事情提供更清晰的错误消息,但安全方面我理解为什么.
对于试图在尝试这样的事情时弄清楚什么是错误的人,我建议创建一个具有完全访问权限的个人访问令牌:
设置>开发人员设置>个人访问令牌>生成新令牌
通过这种方式,您可以通过将令牌与对所有内容具有访问权限的个人访问令牌进行比较,轻松测试是否是范围问题.
感谢任何仍然花时间阅读此内容的人.
And*_*ris 35
只需使用HTTPS地址以用户身份使用密钥进行克隆,因此:
https://oauth-key-goes-here@github.com/username/repo.git
Run Code Online (Sandbox Code Playgroud)
Ami*_*evy 24
只需像这样使用 HTTP 克隆存储库:
git clone https://github.com/myuser/myrepo.git
Run Code Online (Sandbox Code Playgroud)
当提示输入用户名时,填写您的用户名。
当提示输入密码时,请填写令牌。
t.i*_*ios 10
从这两个选择中做任何对你有用的事情
在你的终端
$ git clone your_repo_url
Username:your_token
Password:
...没有密码
在您的 git 客户端应用程序中
即 Sourcetree、GitKraken 和 GitHub 客户端。
输入您的 repo_url(显然没有“$ git clone 部分”)
Username:your_token
Password:
...没有密码
或者, 即在 Sourcetree 中,打开首选项,然后转到高级,输入主机名(即 www.x.com)和用户名(即 your_token)
去https://github.com/settings/tokens并生成一个新的令牌,记得启用对 repo 的访问权限,之后,您可以执行以下操作来克隆 repo。
git clone https://<token>@github.com/owner/repo.git
Run Code Online (Sandbox Code Playgroud)
对于像未来的我这样的懒人:
从https://github.com/settings/tokens生成“个人访问令牌(经典)”并复制它。(在接下来的步骤中,这将类似于密码。)
运行以下 git 命令。它指示 git 存储凭据(将在步骤 3 中出现)
git config --global credential.helper manager-core
git config --global credential.helper store
Run Code Online (Sandbox Code Playgroud)
在您的第一个克隆中,系统将要求您提供用户名和密码,并提供来自上述第 1 项的密码:
git clone https://mehmetkaplan@github.com/GithubUserName/repo-to-clone.git
Run Code Online (Sandbox Code Playgroud)
对于下一个 git 命令,不应要求您提供凭据。
| 归档时间: |
|
| 查看次数: |
42409 次 |
| 最近记录: |