使用HTTPS访问私有存储库

时间:2014-06-03 07:04:40

标签: git git-clone

尝试克隆私有存储库我有权使用HTTPS协议,因为只允许传出流量。

git不会要求输入密码,只是失败了。

error: The requested URL returned error: 403 Forbidden while accessing https://github.com/blah/blahblah.git/info/refs

我错过了什么?

3 个答案:

答案 0 :(得分:72)

您是否尝试在克隆网址中插入用户名(以及可选的密码)?

 git clone https://username@github.com/blah/blahblah.git

或者如果您接受以简单的视图存储密码的后果:

 git clone https://username:password@github.com/blah/blahblah.git

请参阅此主题并提供大量有用的信息:

How to provide username and password when run "git clone git@remote.git"?

编辑:我原来的答案只是一个快速修复,不了解提问者的完整历史,它也无人值守,但为了最好的安全实践,最好让Git存储您的密码。请参阅@ phpguru的答案:https://stackoverflow.com/a/29018371/257090

答案 1 :(得分:36)

@mrjoltcola的答案应该有效,但是如果您不想在命令行上以明文的形式将github密码放在服务器的bash_history中,那么您可以省略密码并提示输入密码:

git clone https://username@github.com/organizationname/reponame.git
Password:

我更喜欢这样。

答案 2 :(得分:1)

如果您使用的是双重身份验证,请先转到此链接:

  

https://github.com/settings/tokens

创建一个令牌,然后将其用作密码:

git clone https://username:token@github.com/blah/blahblah.git