简体   繁体   English

使用终端的私有存储库的Git克隆失败

[英]Git clone fails for private repository using Terminal

I am trying to clone a private repository using the Terminal, but it fails stating the following errors: 我正在尝试使用终端克隆专用存储库,但是它未能说明以下错误:

  1. The repository does not exist. 该存储库不存在。
  2. Failure connecting with credentials. 使用凭据连接失败。

I can successfully clone the same repo using xCode & Source Tree. 我可以使用xCode和Source Tree成功克隆相同的存储库。 I've added & verified SSH key & tried HTTP & SSH but the clone fails in both cases. 我已经添加并验证了SSH密钥并尝试了HTTP和SSH,但在两种情况下克隆均失败。

What am I missing here? 我在这里想念什么?

After many attempts I've found the solution. 经过多次尝试,我找到了解决方案。 When you have to clone a private directory, git clone command changes a bit. 当您必须克隆私有目录时,git clone命令会稍作更改。 Usually what we do is 通常我们要做的是

git clone https://github.com/zzzubair/TestGit.git

which is fine if TestGit is public repository. 如果TestGit是公共存储库,则很好。 But for private repository you've to mention your user name, which has right access to clone the repository, so this command changes to this. 但是对于私有存储库,您必须提及您的用户名,该用户名具有克隆存储库的权限,因此此命令更改为此名称。

git clone https://zzzubair@github.com/zzzubair/TestGit.git

I hope this'll help many others who are or will face the issue. 希望这会帮助许多正在或将要面对这个问题的人。

If you're using github and windows, verify that you generate your personal access tokens ( more info here ) and select the "repo" option (Full control of private repositories). 如果您使用的是github和Windows,请验证您是否生成了个人访问令牌( 更多信息在此处 ),然后选择“ repo”选项(完全控制私有存储库)。 Else, your token will be useful for public repositories. 否则,您的令牌将对公共存储库有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM