Git 著名的“错误:用户对 .git 的权限被拒绝”

发布于 2024-10-24 07:50:48 字数 4243 浏览 1 评论 0 原文

我尝试过谷歌搜索并通读 https://help.github。 com/en/articles/connecting-to-github-with-ssh 和各种指南。我无法git push -u origin mastergit push origin master(相同的命令)。

我的 git 帐户已经使用至少两年左右了。我已经成功地在我的笔记本电脑上创建了存储库并 push -u origin master ,但在这个台式机上我遇到了问题。

这是我尝试过的:

1.我已经设置了我的 git 用户名

2.我已经设置了我的 git 用户电子邮件

3.我已经上传了我的 /home/meder/.ssh/id_rsa.pub 的内容到 github 的帐户页面。我已验证我没有粘贴任何空格

4。 我已使用以下内容创建了 ~/.ssh/config:

  Host github.com
  User git
  Hostname github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

我已将 .ssh chmodded 为 700,id_rsa 600

5。强>我已经添加了正确的远程源没有输入错误git远程添加源[电子邮件受保护]:medero/cho.git

6 .为了确认#5,这是我的 .git/config。该目录正确,而不是另一个目录:

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = [email protected]:medero/cho.git

7. ssh [email protected] -v 给了我一个成功的身份验证

8.一件奇怪的事情是,它向我打招呼的用户名后面附加了t。我的 github 用户名是 medero,而不是 medert

嗨梅德罗!你已经成功了 经过身份验证,但 GitHub 没有 提供 shell 访问。

9.不在代理或防火墙后面

10. 提供了密钥,这是 -v

debug1:主机“github.com”已知并且与 RSA 主机密钥匹配。
debug1:在 /home/meder/.ssh/known_hosts:58 中找到密钥
debug1:ssh_rsa_verify:签名正确
debug1:SSH2_MSG_NEWKEYS 已发送
debug1:期待 SSH2_MSG_NEWKEYS
debug1:收到 SSH2_MSG_NEWKEYS
debug1:已发送 SSH2_MSG_SERVICE_REQUEST
debug1:收到 SSH2_MSG_SERVICE_ACCEPT
debug1:可以继续的身份验证:publickey
debug1:下一个身份验证方法:publickey
debug1:提供公钥:/home/meder/.ssh/id_rsa
debug1:远程:强制命令:gerve mederot
debug1:远程:端口转发已禁用。
debug1:远程:X11 转发已禁用。
debug1:远程:代理转发已禁用。
debug1:远程:Pty 分配已禁用。
debug1:服务器接受密钥:{一些东西,不知道我是否应该分享它

debug1:远程:强制命令:gerve mederot
debug1:远程:端口转发已禁用。
debug1:远程:X11 转发已禁用。
debug1:远程:代理转发已禁用。
debug1:远程:Pty 分配已禁用。
debug1:身份验证成功(公钥)。

11. 以下是我使用的命令

mkdir cho
git init
touch README
git add README
git commit -m 'test'
git remote add origin [email protected]:medero/cho.git
git push -u origin master

12. 我不想创建新的 SSH 密钥。

13. 如果我使用 ssh 进行 git clone 并进行编辑、提交和 git Push,我会得到同样的结果。

14. 这是实际的错误:

$ git push
ERROR: Permission to medero/cho.git denied to mederot.
fatal: The remote end hung up unexpectedly

15. 我已经设置了我的 github 用户名和 github 令牌:

$ git config --global github.user medero $ git config --global github.token 0123456789yourf0123456789token为系统上的所有 git 实例设置 GitHub 令牌

16。 我已确认我的 github 用户名不是 mederot 而我的 github 令牌是根据我的帐户页面正确(已验证前 2 个字符和最后 2 个字符)。

17。为了确认#16,~/.gitconfig包含

[github]
    token = mytoken...
    user = medero

18。我做了ssh-key add ~/.ssh/id_rsa如果这是偶数必要...



理论:

我怀疑有什么可疑之处,因为当我通过 ssh 身份验证时,用户问候语是 mederot 而不是 medero,这是我的帐户。我的 github 帐户中的某些内容是否可能被错误缓存?

我还怀疑本地 ssh 缓存有一些奇怪的地方,因为如果我 mv ~/.ssh/id_rsa KAKAmv ~/.ssh/id_rsa.pub POOPOO,并执行 ssh [电子邮件受保护] -v,当我重命名它时,它仍然对我进行身份验证并说它为我的 /home/meder/.ssh/id_rsa 提供服务?!一定要缓存吗?!

I have tried googling and read through https://help.github.com/en/articles/connecting-to-github-with-ssh and various, various guides. I am unable to git push -u origin master or git push origin master ( the same command ).

I've had my git account for at least 2 or so years. I've successfully been able to create repos and push -u origin master fine on my laptop but on this desktop I'm having issues.

Here's what I tried:

1. I have setup my git user name

2. I have setup my git user email

3. I have uploaded the contents of my /home/meder/.ssh/id_rsa.pub to github's account page. I have verified I did not paste any whitespace

4. I have created a ~/.ssh/config with these contents:

  Host github.com
  User git
  Hostname github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

I have chmodded the .ssh to 700, id_rsa 600

5. I have added the proper remote origin without making typos : git remote add origin [email protected]:medero/cho.git

6. To confirm #5, here is my .git/config. The directory is correct and not another directory:

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = [email protected]:medero/cho.git

7. ssh [email protected] -v gives me a successful Authentication

8. One weird thing is, the username which it greets me with has t appended to it. My github username is medero, not medert.

Hi mederot! You've successfully
authenticated, but GitHub does not
provide shell access.

9. I am not behind a proxy or firewall

10. The key is offered, heres the output from -v:

debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/meder/.ssh/known_hosts:58
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/meder/.ssh/id_rsa
debug1: Remote: Forced command: gerve mederot
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: { some stuff, dont know if i should share it

debug1: Remote: Forced command: gerve mederot
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Authentication succeeded (publickey).

11. Here are the commands I used

mkdir cho
git init
touch README
git add README
git commit -m 'test'
git remote add origin [email protected]:medero/cho.git
git push -u origin master

12. I don't want to create a new SSH key.

13. If I git clone using ssh and make an edit, commit, and git push, I get the same exact thing.

14. Here's the actual error:

$ git push
ERROR: Permission to medero/cho.git denied to mederot.
fatal: The remote end hung up unexpectedly

15. I have setup my github username and github token:

$ git config --global github.user medero
$ git config --global github.token 0123456789yourf0123456789tokenSets the GitHub token for all git instances on the system

16. I have confirmed my github username is NOT mederot and my github token IS CORRECT per my account page ( validated first 2 chars and last 2 chars ).

17. To confirm #16, ~/.gitconfig contains

[github]
    token = mytoken...
    user = medero

18. I did ssh-key add ~/.ssh/id_rsa if that's even necessary...

THEORIES:

I suspect there's something fishy because when I get ssh authenticated, the user greeting is mederot and not medero, which is my acct. Could something in my github account possibly be incorrectly cached?

I also suspect some local ssh caching weirdness because if i mv ~/.ssh/id_rsa KAKA and mv ~/.ssh/id_rsa.pub POOPOO, and do ssh [email protected] -v, it still Authenticates me and says it serves my /home/meder/.ssh/id_rsa when I renamed it?! It has to be cached?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(20

心凉怎暖 2024-10-31 07:50:48

经过几天的谷歌搜索,我发现这是唯一与我的情况相似的问题。

不过,我刚刚解决了这个问题!因此,我将我的答案放在这里,以帮助其他搜索此问题的人。

这是我所做的:

  1. 打开“Keychain Access.app”(您可以在 Spotlight 或 LaunchPad 中找到它)

  2. 在类别中选择“所有项目”

  3. 搜索“git”

  4. 删除所有旧的和新的内容。奇怪的项目

  5. 再次尝试推送,它就成功了

After Googling for few days, I found this is the only question similar to my situation.

However, I just solved the problem! So I am putting my answer here to help anyone else searching for this issue.

Here is what I did:

  1. Open "Keychain Access.app" (You can find it in Spotlight or LaunchPad)

  2. Select "All items" in Category

  3. Search "git"

  4. Delete every old & strange item

  5. Try to Push again and it just WORKED

夜无邪 2024-10-31 07:50:48

如果 Windows 出现问题,请从 Windows 历史记录中删除凭据。

  • 转到凭据管理器
  • 转到 Windows 凭据
  • 删除通用凭据下的条目
  • 再次尝试连接。这一次,它应该提示您输入正确的用户名和密码。

输入图像描述这里
输入图像描述这里

从 git 删除凭据

If problem is coming on windows then remove the Credentials from the Windows history.

  • Go to Credential Manager
  • Go to Windows Credentials
  • Delete the entries under Generic Credentials
  • Try connecting again.This time , it should prompt you for the correct username and password.

enter image description here
enter image description here

remove credentials from git

烧了回忆取暖 2024-10-31 07:50:48

在 Mac 上,如果您有多个 GitHub 登录名并且使用 SSH,请使用以下命令强制正确登录:

git remote set-url origin https://[email protected]/username/repo-name.git

如果您在推送到私有存储库时遇到问题,这也适用。

On Mac, if you have multiple GitHub logins and are not using SSH, force the correct login by using:

git remote set-url origin https://[email protected]/username/repo-name.git

This also works if you're having issues pushing to a private repository.

逆光下的微笑 2024-10-31 07:50:48

在第 18 步中,我假设您的意思是 ssh-add ~/.ssh/id_rsa?如果是这样,那就解释了:

我还怀疑一些本地 ssh 缓存怪异,因为如果我 mv ~/.ssh/id_rsa KAKA 和 mv ~/.ssh/id_rsa.pub POOPOO,并执行 ssh [email protected] -v,当我重命名它时,它仍然对我进行身份验证并表示它为我的 /home/meder/.ssh/id_rsa 提供服务?!它必须被缓存?!

...因为 ssh-agent 正在缓存您的密钥。

如果你查看 GitHub,就会发现有一个 mederot 帐户。你确定这件事与你无关吗? GitHub 不应允许将相同的 SSH 公钥添加到两个帐户,因为当您使用 [电子邮件受保护]:... 它根据 SSH 密钥识别用户的 URL。 (此处确认不允许这样做.)

因此,我怀疑(按可能性降序排列)存在以下情况之一:

  1. 您之前创建了 mederot 帐户并向其中添加了 SSH 密钥。
  2. 其他人已获取您的公钥副本并将其添加到 mederot GitHub 帐户。
  3. GitHub 上有一个可怕的错误。

如果 1 不是这种情况,那么我会将其报告给 GitHub,以便他们可以检查大约 2 或 3。

更多:

ssh-add -l 检查是否存在多个标识
如果是,通过 ssh-add -d "that key file" 删除它

In step 18, I assume you mean ssh-add ~/.ssh/id_rsa? If so, that explains this:

I also suspect some local ssh caching weirdness because if i mv ~/.ssh/id_rsa KAKA and mv ~/.ssh/id_rsa.pub POOPOO, and do ssh [email protected] -v, it still Authenticates me and says it serves my /home/meder/.ssh/id_rsa when I renamed it?! It has to be cached?!

... since the ssh-agent is caching your key.

If you look on GitHub, there is a mederot account. Are you sure that this is nothing to do with you? GitHub shouldn't allow the same SSH public key to be added to two accounts, since when you are using the [email protected]:... URLs it's identifying the user based on the SSH key. (That this shouldn't be allowed is confirmed here.)

So, I suspect (in decreasing order of likelihood) that one of the following is the case:

  1. You created the mederot account previously and added your SSH key to it.
  2. Someone else has obtained a copy of your public key and added it to the mederot GitHub account.
  3. There's a horrible bug in GitHub.

If 1 isn't the case then I would report this to GitHub, so they can check about 2 or 3.

More :

ssh-add -l check if there is more than one identify exists
if yes, remove it by ssh-add -d "that key file"

二智少女 2024-10-31 07:50:48

其原因是冲突。

清除 ssh-agent 中的所有密钥

ssh-add -d ~/.ssh/id_rsa
ssh-add -d ~/.ssh/github

添加 github ssh 密钥

ssh-add   ~/.ssh/github

现在应该可以工作了。

Its due to a conflict.

Clear all keys from ssh-agent

ssh-add -d ~/.ssh/id_rsa
ssh-add -d ~/.ssh/github

Add the github ssh key

ssh-add   ~/.ssh/github

It should work now.

凡尘雨 2024-10-31 07:50:48

我使用的是 Mac,通过从钥匙串访问应用程序中删除 github 记录解决了该问题:
这就是我所做的:

  1. 打开“Keychain Access.app”(您可以在 Spotlight 或 LaunchPad 中找到它)
  2. 在类别中选择“所有项目”
  3. 搜索“git”
  4. 删除所有旧的和新的项目。奇怪的项目再次尝试推送,它就成功了

以上步骤是从@spyar复制的,以方便起见。

I am using Mac and the issue is solved by deleting github record from keychain access app:
Here is what i did:

  1. Open "Keychain Access.app" (You can find it in Spotlight orLaunchPad)
  2. Select "All items" in Category
  3. Search "git"
  4. Delete every old & strange items Try to Push again and it just WORKED

Above steps are copied from @spyar for the ease.

玉环 2024-10-31 07:50:48

我发现解决方案与 @spyar 提供的解决方案相同,即存储旧用户名的钥匙串访问应用程序。

对于这种情况有两种解决方案:

  1. 删除钥匙串访问中的信息
    • 打开钥匙串访问应用
    • 搜索GitHub
    • 删除相应的凭据

  1. 如果您想使用ssh密钥。您只需将您的 Repo url 从 https 更改为

    <块引用>

    https://github.com/username/repo.git

    进入

    <块引用>

    [电子邮件受保护]:用户名/repo.git

I find the solution is the same as @spyar provide which is the Keychain Access app stored the old username.

There are 2 solutions for this situation:

  1. Delete the info in Keychain Access by
    • Open Keychain Access app
    • Search for GitHub
    • Delete corresponding credentials

Or

  1. If you want to use ssh key. You just change your Repo url from https

    https://github.com/username/repo.git

    into

    [email protected]:username/repo.git

逆夏时光 2024-10-31 07:50:48

我在 Mac 操作系统上遇到了类似的问题。

摘要

  1. 确保使用正确/预期的用户名克隆存储库
  2. 如果您尝试在不指定 GitHub 用户名的情况下克隆存储库,它会获取已缓存在 OSX 的 Keychain Access 实用程序中的 GitHub 用户名,
  3. 因此我必须在克隆存储库时指定用户名 - <代码>git克隆 https://[电子邮件受保护]/用户名/存储库.git
  4. 当提示输入密码时,您可能必须使用个人访问令牌 (PAT),因为 GitHub 已于 2021 年 8 月 13 日删除了对密码身份验证的支持。以下是有关 个人访问令牌 (PAT)以及如何设置和使用
  5. 初始推送可能还需要指定用户名git push https://[email protected]/username/repository.git 并提供 PAT 作为密码
  6. 在后续推送中,获取密码时不会提示任何密码缓存到 OSX Keychain Access util。另外,我不必使用完整的 URL 来推送。只需 git push 即可 工作正常

有关我的设置/情况/问题的更多详细信息

本质上,我试图使用两个不同的 GitHub (github.com) 帐户(1. 工作帐户/电子邮件 & 2. 个人帐户/我

的情况有点特殊,因为在将我们的存储库迁移到公共 github.com 之前,当我们的组织在本地时,我有一个使用我的个人电子邮件生成的现有 SSH 密钥,并且该密钥也是为 Bastion AWS(Amazon Web Services)配置的。我无法使用同一电子邮件重新生成新密钥,也没有使用工作电子邮件生成新密钥,这需要更新为 Bastion AWS 配置的密钥

注意:我的初始设置本身不正确,因为当时我对如何使用或使用 SSH 密钥不太了解,所以我意识到我设置不正确

以下方法对我有用(请注意,这是一个解决方法)。我转而使用 GitHub 个人访问令牌 (PAT)。

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

提示密码时,我在这里输入了我的 PAT(然后将其缓存到 OSX Keychain Access),

然后

git push https://[email protected]/username/repository.git

在我后续的推送中,没有密码提示,并且我不必使用完整的 URL 来推送。只需 git push 即可 工作正常

I was running into similar issue on Mac OS.

Summary

  1. Make sure the repo gets cloned with correct/intended username
  2. If you try to clone a repo without specifying GitHub username, it picks up the GitHub username already cached in the OSX's Keychain Access utility
  3. Hence I had to specify username while cloning the repo - git clone https://[email protected]/username/repository.git
  4. When it prompts to enter password, you may have to use a use a personal access token (PAT) because support for password authentication was removed on August 13, 2021 by GitHub. Here's some documentation around personal access tokens (PAT) and how to set up and use
  5. The initial push might also require specifying username git push https://[email protected]/username/repository.git and providing PAT as password
  6. On subsequent pushes, no password would be prompted as they get cached to OSX Keychain Access util. Also, I didn't have to use the full URL to push. Just git push <origin/remote/upstream> <branch> worked fine

More details about my set up/situation/issue

Essentially I was trying to work with two different GitHub (github.com) accounts (1. Work account/email & 2. Personal account/email)

Mine was a little peculiar case because I had an existing SSH key generated with my personal email when our organization was on premise before migrating our repos to public github.com and that key was also configured for Bastion AWS (Amazon Web Services). I couldn't regenerate a new key with the same email and also I did not generate a new key with work email which would have required to update the key configured for Bastion AWS

Note: My initial set up itself wasn't correct because at that time I didn't have much knowledge about how to work with or use SSH keys, so I realized I set them up incorrectly

Following approach worked for me (Note that this is a work around). I fell back to using GitHub Personal Access Token (PAT) instead.

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

Prompted password, I entered my PAT here (which then got cached to OSX Keychain Access)

And then

git push https://[email protected]/username/repository.git

On my subsequent pushes, no password prompts and I didn't have to use the full URL to push. Just git push <origin/remote/upstream> <branch> worked fine

烙印 2024-10-31 07:50:48

我最近在我的机器上的旧存储库上遇到了这个问题,该存储库是使用 https 推送的。步骤 5 和 6 通过将我的存储库的远程 url 从使用 https url 重新设置为 ssh url 解决了我的问题,

检查远程是否使用 https url,

> git remote -v
origin  https://github.com/ExampleUser/ExampleRepo.git (fetch)
origin  https://github.com/ExampleUser/ExampleRepo.git (push)

然后重新设置源以使用 ssh url

> git remote set-url origin [email protected]:ExampleUser/ExampleRepo.git

验证新的远程

> git remote -v
origin  [email protected]:ExampleUser/ExampleRepo.git (fetch)
origin  [email protected]:ExampleUser/ExampleRepo.git (push)

现在可以成功 git push -u origin

我仍然不确定我会更改哪些设置,这可能会导致远程为 https 时推送失败,但这是我的问题的解决方案

I recently ran into this issue for on old repo on my machine that had been pushed up using https. steps 5 and 6 solved my issue by re-setting the remote url for my repo from using the https url to the ssh url

checking the remote is using the https url

> git remote -v
origin  https://github.com/ExampleUser/ExampleRepo.git (fetch)
origin  https://github.com/ExampleUser/ExampleRepo.git (push)

then re-setting the origin to use the ssh url

> git remote set-url origin [email protected]:ExampleUser/ExampleRepo.git

verifying new remote

> git remote -v
origin  [email protected]:ExampleUser/ExampleRepo.git (fetch)
origin  [email protected]:ExampleUser/ExampleRepo.git (push)

could now successfully git push -u origin

i'm still not sure what setting i would have changed that might have caused the push to fail when the remote is https but this was the solution to my issue

单身狗的梦 2024-10-31 07:50:48

我和你有同样的问题。经过很长时间的谷歌搜索后,我发现我的错误是由多个用户在其帐户中添加了相同的密钥引起的。

所以,这是我的解决方案:删除错误用户的 ssh 密钥(我可以这样做,因为错误用户也是我的帐户)。如果错误的用户不是您的帐户,您可能需要更改您的 ssh 密钥,但我认为这种情况不会发生。

我认为您的问题可能是由于您的帐户名称输入错误造成的。

I had the same problem as you. After a long time spent Googling, I found out my error was caused by multiple users that had added the same key in their accounts.

So, here is my solution: delete the wrong-user's ssh-key (I can do it because the wrong-user is also my account). If the wrong-user isn't your account, you may need to change your ssh-key, but I don't think this gonna happen.

And I think your problem may be caused by a mistyping error in your accounts name.

Hello爱情风 2024-10-31 07:50:48

我在使用 Travis CI 部署内容时遇到此错误,其中涉及推送编辑到存储库。

我最终通过使用 个人访问令牌 解决了该问题>public_repo 范围访问权限:

选择 <code>public_repo</code>

I encountered this error when using Travis CI to deploy content, which involved pushing edits to a repository.

I eventually solved the issue by updating the GitHub personal access token associated with the Travis account with the public_repo scope access permission:

Select <code>public_repo</code>

楠木可依 2024-10-31 07:50:48

在推送到存储库时观察到同样的问题:

$ git push --set-upstream origin new-operator-test
ERROR: Permission to redhat-openshift-ecosystem/redhat-marketplace-operators.git denied to cniackz.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

所做的就是确保克隆您的分叉存储库:

git clone [email protected]:cniackz/redhat-marketplace-operators.git
git checkout -b new-branch
<performed the changes>
git add <files>
git commit -m <files>

并且它起作用了:

$ git push --set-upstream origin new-branch
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 10 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 643 bytes | 643.00 KiB/s, done.
Total 7 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: 
remote: Create a pull request for 'new-branch' on GitHub by visiting:
remote:      https://github.com/cniackz/redhat-marketplace-operators/pull/new/new-branch
remote: 
To github.com:cniackz/redhat-marketplace-operators.git
 * [new branch]      new-branch -> new-branch
Branch 'new-branch' set up to track remote branch 'new-branch' from 'origin'.

怀疑一开始,它没有使用分叉存储库,而是使用了来自 redhat 的存储库,这可以解释由于 cniackz 用户无权访问该存储库,而只能访问 fork,因此出现此问题。

Same issue was observed when pushing to a respository:

$ git push --set-upstream origin new-operator-test
ERROR: Permission to redhat-openshift-ecosystem/redhat-marketplace-operators.git denied to cniackz.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What was done is making sure you clone your forked repository:

git clone [email protected]:cniackz/redhat-marketplace-operators.git
git checkout -b new-branch
<performed the changes>
git add <files>
git commit -m <files>

And it worked:

$ git push --set-upstream origin new-branch
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 10 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 643 bytes | 643.00 KiB/s, done.
Total 7 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: 
remote: Create a pull request for 'new-branch' on GitHub by visiting:
remote:      https://github.com/cniackz/redhat-marketplace-operators/pull/new/new-branch
remote: 
To github.com:cniackz/redhat-marketplace-operators.git
 * [new branch]      new-branch -> new-branch
Branch 'new-branch' set up to track remote branch 'new-branch' from 'origin'.

It is suspected that to start with, it was not used the forked repository but the one from redhat and this would explain the issue since cniackz user does not have access to that repository but to forked only.

挽手叙旧 2024-10-31 07:50:48

就我而言,我的两个帐户有两个不同的 ssh 密钥。一种用于工作,一种用于个人 github 帐户。我通过更改 .ssh/config 文件和 git 远程 url 解决了这个问题。

起初我的 .ssh/config 文件如下所示:

Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ssh_work

我的 git 远程 url 是 [email  protected]:myusername/my-repo-name.git

然后首先我改变了.ssh/config 文件添加两个主机,如下所示:

#Github Work Account
Host git_work
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_work

#Github Personal account
Host git_personal
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_personal

#General
Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ssh_work

并将 git 远程 url 替换为 git_personal:myusername/my-repo-name.git 通过替换 "[email protected]" 和“git_personal”是我在配置文件中提供的主机名。

但它仍然不起作用,然后我只是从 .ssh/config 中删除“Host *”相关部分,它就起作用了。所以最后我的 .ssh/config 如下所示:

#Github Work Account
Host git_work
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_work

#Github Personal account
Host git_personal
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_personal

然后最后错误消失了并且它起作用了。如果有像我这样的情况,希望有人能从中受益。

In my case, I had two different ssh key for two account. One was for work and one was for personal github account. I resolved it by changing the .ssh/config file and git remote url.

At first my .ssh/config file was like below:

Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ssh_work

And my git remote url was [email protected]:myusername/my-repo-name.git

Then first I changed the .ssh/config file with adding two hosts like following:

#Github Work Account
Host git_work
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_work

#Github Personal account
Host git_personal
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_personal

#General
Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ssh_work

And git remote url to git_personal:myusername/my-repo-name.git by replacing "[email protected]" with "git_personal" the hostname that I gave in config file.

But still it was not work then I just remove the "Host *" related portion from the .ssh/config the it worked. So at last my .ssh/config was like below:

#Github Work Account
Host git_work
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_work

#Github Personal account
Host git_personal
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ssh_personal

Then finally the error was gone and it worked. Hopefully someone may benefit from it if there case is similar like me.

萧瑟寒风 2024-10-31 07:50:48

这个问题也是由以下原因引起的:

如果您使用的是 mac/linux,并且在 ~/.ssh/config 中使用“ControlMaster”,则可能有一些 ssh 控制主进程正在运行。

要找到它们,请运行:

ps aux | grep '\[mux\]'

并杀死相关的。

This problem is also caused by:

If you are on a mac/linux, and are using 'ControlMaster' in your ~/.ssh/config, there may be some ssh control master processes running.

To find them, run:

ps aux | grep '\[mux\]'

And kill the relevant ones.

中性美 2024-10-31 07:50:48

我也遇到了这个问题,对我来说造成这个问题的原因是,在克隆我正在推送更改的存储库时,我在没有登录的情况下从隐身选项卡中获取了克隆 URL。(我仍然不知道它是如何影响的)。由于某种原因,这导致 git 选择另一个用户帐户。
当我从正确的登录页面再次尝试时,它对我来说就像平常一样。

I too ran into this, what caused this for me is that while cloning the repo I was pushing my changes to, I picked up the clone URL from an incognito tab without signing in. (I am still clueless on how it effects). That for some reason led to git picking another user account.
When i tried it again from a proper signed in page it worked like usual for me.

笑忘罢 2024-10-31 07:50:48

我在使用 MAC 时也碰巧遇到了这个问题
所以,问题是这样的。我曾经从我的旧 GitHub 帐户之一登录过。现在,我使用不同的 GitHub 帐户。
我使用以下步骤解决了 -

  1. 打开“Keychain Access.app”
  2. 中选择“所有项目”
  3. 在类别搜索“Github”
  4. 打开该条目,
  5. 并将帐户更改为新的 github 用户名。

再次尝试 Push 就可以了

I also happen to come across this issue while working on my MAC
So, the problem is this. I had once logged in from one of my old GitHub account. Now, I am using a different GitHub account.
I solved using the below steps-

  1. Open "Keychain Access.app"
  2. Select "All items" in Category
  3. Search "Github"
  4. Open that entry,
  5. and change the Account to new github username.

Try to Push again and it will work

只是在用心讲痛 2024-10-31 07:50:48

对我有帮助的步骤:

  1. 删除所有现有的 PAT 在 github 上并创建了一个新的。
  2. 请务必检查    存储库     创建新 PAT 时的部分。以下是来自 github 的图片作为示例:
    上述链接的第 8 步
    对我来说,这一步是错误的根源,因为我正确地遵循了上面的步骤 1
  3. 更新本地计算机中的 github 密码 Windowsmac

这就是我的想法。

Steps that help me:

  1. Deleted all the existing PATs on github and created a new one.
  2. Make sure to check the     repo     section when creating a new PAT. Following is image from github as example:
    step 8 of the above link
    For me this step was the source for the error, since I followed the above step 1 correctly.
  3. Update you github password in your local machine windows or mac

That's all I think.

清风挽心 2024-10-31 07:50:48

我在尝试从组织克隆私有存储库时遇到了这个问题。就我而言,解决方案是从 GitHub 中删除 SSH 密钥并添加一个新密钥。

I ran into this issue when trying to clone a private repository from an organization. In my case the solution was to delete the SSH key from GitHub and add a new one.

满身野味 2024-10-31 07:50:48

就我而言,我只是没有被添加到我想要贡献其存储库的组织中,其他一切都已设置完毕。所以我要求组织所有者添加我,结果成功了。

In my case, I simply wasn't added to the organization whose repository I want to contribute to, everything else was set up. So I asked the organisation owner to add me, and it worked.

呆橘 2024-10-31 07:50:48

错误搜索目的:

错误:远程:USERNAME-2 对 USERNAME-1/REPONAME.git 的权限被拒绝。
致命:无法访问“https://github.com/USERNAME-1/repo.git/”:
请求的 URL 返回错误:403

错误:无法将某些引用推送到 'https://github.com/user/repo.git

错误:您无权推送到 github 上的“repo”。你是否想要
创建一个叉子并推入它,而不是

我遇到了这个错误^。所以我遵循这个对我有用。

我的解决方案:

我删除了所有 .git 或 git 凭据。没有别的。

希望这对流浪的同伴有所帮助。

ERROR SEARCH PURPOSES:

error: remote: Permission to USERNAME-1/REPONAME.git denied to USERNAME-2.
fatal: unable to access 'https://github.com/USERNAME-1/repo.git/': The
requested URL returned error: 403

error: failed to push some refs to 'https://github.com/user/repo.git

error: you dont have permission to push to "repo" on github. would you like to
create a fork and push to it instead

I had this error ^. so i followed this and it worked for me.

my solution:

i deleted all .git or git credentials. nothing else.

hope this helps a fellow wanderer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文