如何使用 git-remote-https 解决权限被拒绝错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7161227/
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 05:53:11  来源:igfitidea点击:

How can I resolve a permission denied error with git-remote-https?

gitgithub

提问by nivanka

I'm having trouble trying to clone a GitHub repository with the following command:

我在尝试使用以下命令克隆 GitHub 存储库时遇到问题:

git clone https://[email protected]/MYPROJECT.git

When I run it, I get this error:

当我运行它时,我收到此错误:

fatal: cannot exec 'git-remote-https': Permission denied

How can I resolve it?

我该如何解决?

采纳答案by VonC

Try:

尝试:

 git clone https://github.com/username/MYPROJECT

Which should be the correct http address (instead of trying to access github through an ssh session) for a publicrepo.
It will take advantage of their support for smart http.

哪个应该是公共存储库的正确 http 地址(而不是尝试通过 ssh 会话访问 github)。
它将利用他们对智能 http支持

 git clone https://[email protected]/username/project.git

is for private repo (as explained here), which should work if your id is right and your public ssh key correctly updated on your GitHub account.
(Note: your original address was missing the /username/part)

用于私有存储库(如此处所述),如果您的 id 正确并且您的公共 ssh 密钥在您的 GitHub 帐户上正确更新,它应该可以工作。
(注意:您的原始地址缺少该/username/部分)

The OP reports:

OP 报告:

my RSA keys were not used when authenticating, I did a ssh-addand added them.
After that it worked figured it out by running ssh -vT [email protected]in my terminal

验证时没有使用我的 RSA 密钥,我做了一个ssh-add并添加了它们。
之后它通过ssh -vT [email protected]在我的终端中运行来解决它

回答by Grad van Horck

Every GitHub project has a 'clone url' widget to help you select the URL you need. Select it's access method (GIT/HTTP/etc.) and copy the url.

每个 GitHub 项目都有一个“克隆 url”小部件,可帮助您选择所需的 URL。选择它的访问方法(GIT/HTTP/etc.)并复制 url。

If it's your own project (/ have write access to the project):

如果它是您自己的项目(/对该项目具有写访问权限):

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

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

or

或者

git clone https://[email protected]/username/project.git

git clone https://[email protected]/username/project.git

If you want a readonly clone:

如果你想要一个只读克隆:

git clone https://github.com/username/project.git

git clone https://github.com/username/project.git