GitHub not letting to push after resetting keys triple times, based on their tutorial, based on bitbucket tutorial, still denied

huangapple go评论68阅读模式
英文:

GitHub not letting to push after resetting keys triple times, based on their tutorial, based on bitbucket tutorial, still denied

问题

你好,JC!看起来你已经成功通过SSH验证,但在进行推送操作时遇到了问题。这可能是因为远程存储库已经存在并与本地存储库关联。

你可以尝试以下步骤来解决问题:
1. 首先,确保你的本地存储库配置正确,它应该指向你的GitHub存储库。可以使用以下命令检查:

git remote -v

确保origin指向正确的GitHub存储库地址。

2. 如果origin正确配置,尝试删除它并重新添加:

git remote remove origin
git remote add origin https://github.com/bananauser/bananaprojectmanager.git


3. 然后再次尝试推送到主分支:

git push -u origin main


如果这些步骤都无法解决问题,请提供更多信息,以便我可以提供更多帮助。
英文:
banana@banana-pc:~/Projects/bananaproject$ git remote add origin https://github.com/bananauser/bananaprojectmanager.git
error: remote origin already exists.
banana@banana-pc:~/Projects/bananaproject$ git push -u origin main
Username for 'https://github.com': ^C
banana@banana-pc:~/Projects/bananaproject$ ssh -T git@github.com
Hi bananauser! You've successfully authenticated, but GitHub does not provide shell access.
banana@banana-pc:~/Projects/bananaproject$

How can I be authenticated and not being able to push?

  • I added my public key to my profile settings "SSH and GPG KEYS".
  • I added my key to the ssh agent.
  • I am authenticated based on ssh -T git@github.com
  • I am just trying to initialise new repository and make a first push.

Note that on ssh -T git@github.com it also gives me correct github account name which is totally dissimilar to everything I have named on my pc.

JC.

答案1

得分: 1

当推送时,它要求您提供https://github.com的用户名,因此您的远程设置为使用HTTPS,https://github.com/bananauser/bananaprojectmanager.git,而不是该存储库的SSH远程,即git@github.com:bananauser/bananaprojectmanager.git

可以通过以下方式修复:

git remote set-url origin git@github.com:bananauser/bananaprojectmanager.git

当远程设置为HTTPS(查看 git remote -v 来检查它)时,您的SSH验证将不起作用。值得注意的是,以这种方式验证SSH身份只是验证设置为尝试连接到该主机的第一个成功尝试的密钥是否是某个用户的已验证密钥,而不一定是存储库所有者的密钥。如果您有多个帐户并且要验证特定帐户,需要确保该帐户的密钥是它将尝试用于 github.com 的第一个密钥。

英文:

It asked you to supply your username for https://github.com when pushing, so your remote was set to use HTTPS, https://github.com/bananauser/bananaprojectmanager.git, rather than what would be the SSH remote for that repository, git@github.com:bananauser/bananaprojectmanager.git.

It would have been possible to fix with;

git remote set-url origin git@github.com:bananauser/bananaprojectmanager.git

While the remote (see git remote -v to check it) was set to HTTPS, your SSH authentication wouldn't have mattered. Worth noting as well that verifying SSH authentication in that manner just verifies that the first successful try for a key that is set to be attempted for that host is an authenticated key for some user, not necessarily the owner of a repository, a detail which is important to keep in mind if you have multiple accounts and you're trying to verify a specific one, you need to make sure the key for that account it the first key it will attempt for github.com.

答案2

得分: 0

我通过从GitHub克隆空项目并将我的项目内容移动到这个克隆的目录来解决了这个问题。为什么GitHub在项目初始化方面让我抓狂,与MSFT有关的任何事情都令人愤怒。所以我的身份验证没问题。

英文:

I solved this by cloning empty project from GitHub and moving the content of my project to this cloned directory. Why github is breaking my nerves with project init is beyond infuriating as anything to do with MSFT.

So my authentication was fine.

huangapple
  • 本文由 发表于 2023年5月25日 22:33:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76333456.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定