我想使用HTTPS协议克隆一个我有访问权限的私有仓库,因为只有出站流量是被允许的。
git没有要求输入密码,直接失败了。
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/blah/blahblah.git/info/refs
我缺少了什么?
git clone https://username@github.com/blah/blahblah.git
或者如果您接受将密码以明文形式存储的后果:
git clone https://username:password@github.com/blah/blahblah.git
参考以下帖子,其中有许多有用的信息:
如何在运行“git clone git@remote.git”时提供用户名和密码?
编辑:我的原始答案只是一个快速修复,没有理解问者的完整历史记录,并且它也可以无人值守地工作,但为了最佳安全实践,最好让Git存储您的密码。请参见@phpguru的答案:https://dev59.com/Y2Ag5IYBdhLWcg3wE3jQ#29018371。
@mrjoltcola的答案应该可以使用,但如果您不想将github密码以明文形式放在服务器的bash_history中,则可以省略密码并提示输入:
git clone https://username@github.com/organizationname/reponame.git
Password:
我更喜欢那个。
创建一个令牌,然后将其用作密码:
git clone https://username:token@github.com/blah/blahblah.git
当我在Linux、macOS或Unix上使用HTTPS连接到AWS CodeCommit存储库时,我遇到了相同的错误。
我需要使用以下命令启用Git凭证UseHttpPath。 git config --global credential.UseHttpPath true
Github 不再允许使用https进行密码验证:您需要改用个人访问令牌。
git clone https://<your_token>@github.com/<username>/<repo_name>.git
如果您尝试使用新帐户登录,即使创建了新令牌,仍可能遇到身份验证失败。您需要设备激活来记住您的凭据。有两种方法,但我强烈推荐使用GitHub CLI。
只需按照下面 GitHub 文档中的步骤进行操作即可。
在输入设备上显示的代码以激活设备后,我可以立即使用git clone。