错误:user1/repo.git 的权限被拒绝给 user2

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

ERROR: Permission to user1/repo.git denied to user2

gitgithubssh-keyspermission-denied

提问by gsingh2011

Someone I know is trying to clone my github repo and make changes directly to it. It's a public repo. He's cloned it with my read-write access link and he can pull from the repo. The problem is when he tries to push anything he gets the error

我认识的某个人试图克隆我的 github 存储库并直接对其进行更改。这是一个公共回购。他用我的读写访问链接克隆了它,他可以从 repo 中提取。问题是当他试图推动任何东西时,他得到了错误

ERROR: Permission to user1/repo.git denied to user2

错误:user1/repo.git 的权限被拒绝给 user2

Where he's user2 and I'm user1. I've allowed other people to use different repos before and I've never had this problem. Am I missing something to allow him access or did github change? I've seen this on the help page for github:

他是user2,我是user1。我之前允许其他人使用不同的 repos,我从来没有遇到过这个问题。我是否错过了允许他访问的内容或 github 是否更改了?我在 github 的帮助页面上看到过这个:

This error occurs when you attach your key as a deploy key on repo1. You can push and pull from that repo without issue, but you won't have access to any other repo with your key. To solve this, remove the key from repo1's deploy keys and attach it on your account page instead. This key will now have access to all repos your account has access to.

当您将密钥附加为 repo1 上的部署密钥时,会发生此错误。您可以毫无问题地从该存储库中推送和拉取,但您将无法使用您的密钥访问任何其他存储库。要解决此问题,请从 repo1 的部署密钥中删除密钥并将其附加到您的帐户页面上。此密钥现在可以访问您的帐户有权访问的所有存储库。

We haven't messed with the deploy keys, but I can't find any other solution on the web.

我们没有弄乱部署密钥,但我在网上找不到任何其他解决方案。

回答by gsingh2011

I was stupid and didn't add them as collaborators.

我很愚蠢,没有将他们添加为合作者。

To do this, follow these instructions:

为此,请按照以下说明操作:

  1. Go to Repository> Admin> Collaborators
  2. You will see a text box with a Addbutton. In order to add a collaborator you start typing in the text box until you see the actual username suggested to you in the drop down list that appears as you type.
  3. Select that username which will cause a green check mark to appear indicating the system recognized that username.
  4. Press Addto add that collaborator to the repository.
  1. 前往Repository> Admin>Collaborators
  2. 您将看到一个带有Add按钮的文本框。为了添加合作者,您开始在文本框中输入,直到您在输入时出现的下拉列表中看到向您建议的实际用户名。
  3. 选择该用户名,这将导致出现绿色复选标记,表明系统已识别该用户名。
  4. Add将该协作者添加到存储库。

You can also watch this octocast: http://screencast.com/t/m7yN19N4645h

你也可以观看这个八进制:http://screencast.com/t/m7yN19N4645h

回答by Lucius Zhao

The problem comes from Windows Credential Manager, and you just need to delete the git account there:

问题来自 Windows Credential Manager,您只需要删除那里的 git 帐户:

Control Panel——>User Account and family Safety——>Manage Windows Credential——>remove the github account

控制面板——>用户账号和家庭安全——>管理Windows凭据——>删除github账号

Windows Credentials

Windows 凭据

回答by Kulenthiran Sayanthan

You first need to remove the last ssh connection.

您首先需要删除最后一个 ssh 连接。

To remove the last ssh connection, follow this command:

要删除最后一个 ssh 连接,请执行以下命令:

ssh-add -D

ssh-add -D

then try to push.

然后尝试推动。

回答by Nguyen Minh

Same problem with me.

和我一样的问题。

If you used git config credential.helper storeto cache your user1credential, you should remove it from cache file.

如果您曾经git config credential.helper store缓存您的user1凭据,则应将其从缓存文件中删除。

You have to edit ~/.git-credentialsfile where your credentials cached.

您必须编辑~/.git-credentials凭据缓存的文件。

Just remove the account you don't need.

只需删除您不需要的帐户。

https://user1:[email protected]
https://user2:[email protected]

回答by Marvin Pinto

GitHub had a minor security breachrecently and as a result, you will need to log in and approve each valid SSH key in your profile. This link to do this is:

GitHub最近发生了轻微的安全漏洞,因此,您需要登录并批准您个人资料中的每个有效 SSH 密钥。执行此操作的链接是:

https://github.com/settings/ssh/audit

https://github.com/settings/ssh/audit

If you're stuck, see thisanswer on how to generate your RSA fingerprint.

如果你坚持,看到这个关于如何生成您的RSA指纹的答案。

回答by Long Nguyen

Updating your credentials via Keychain Accessin macOS

在 macOS 中通过Keychain Access更新您的凭据

  1. In Finder, search for the Keychain Access app.
  2. In Keychain Access, search for github.com.
  3. GitHub Password Entry in KeychainFind the "internet password" entry for github.com.
  4. Edit or delete the entry accordingly.
  1. 在 Finder 中,搜索 Keychain Access 应用程序。
  2. 在 Keychain Access 中,搜索 github.com。
  3. Keychain 中的 GitHub 密码条目找到 github.com 的“互联网密码”条目。
  4. 相应地编辑或删除条目。

回答by Avnish kumar

window user follows this :-

窗口用户遵循此:-

Go to CONTROL PANEL->USER ACCOUNT->Credential Manager->Windows Credential 
->delete all credential related to git

now go to gitbash and proceed as normal,

现在转到 gitbash 并照常进行,

a new popup window will open which ask for your username and password.

将打开一个新的弹出窗口,询问您的用户名和密码。