git clone 显示“已在 xxxxxxxxx(我的目录)中初始化空 Git 存储库”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33862422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:32:44  来源:igfitidea点击:

git clone shows "Initialized empty Git repository in xxxxxxxxx(my directory)"

gitgithub

提问by james

I changed my project repository to private, and when I tried to pull from github it failed. Then I deleted everything in my directory and tried to clone a new repository to my computer, but it also failed.

我将我的项目存储库更改为私有,当我尝试从 github 中提取时它失败了。然后我删除了目录中的所有内容并尝试将新存储库克隆到我的计算机,但它也失败了。

I used "git clone https://github.com/username/myrepo.git" and it said:

我使用了“git clone https://github.com/username/myrepo.git”,它说:

Initialized empty Git repository in xxxxx/myrepo/.git/ error: The requested URL returned error: 403 Forbidden while accessing https://github.com/username/myrepo.git/info/refsfatal: HTTP request failed

在 xxxxx/myrepo/.git/ 中初始化空 Git 存储库错误:请求的 URL 返回错误:403 禁止访问https://github.com/username/myrepo.git/info/refs致命:HTTP 请求失败

Then I also tried "git clone https://[email protected]/username/myrepo.git" and it said:

然后我也尝试了“git clone https://[email protected]/username/myrepo.git”,它说:

Initialized empty Git repository in xxxx/myrepo/.git/

在 xxxx/myrepo/.git/ 中初始化空 Git 存储库

Any thoughts?

有什么想法吗?

回答by mkrufky

Try cloning using the ssh url instead:

尝试使用 ssh url 进行克隆:

git clone [email protected]:username/myrepo.git

回答by Ray Baxter

Error 403 means permission denied. You need to set up your public key on github. Instructions here: https://help.github.com/articles/generating-ssh-keys/

错误 403 表示权限被拒绝。您需要在 github 上设置您的公钥。这里的说明:https: //help.github.com/articles/generating-ssh-keys/