OS: zorin
我使用sshgit clone git@github.com:Organization_Name/Repo_Name.git
克隆了一个公共的repo然后我创建了一个分支,并试图通过使用git push --set-upstream origin My_Branch
推动回购我得到提示输入用户名和密码
Username for 'https://github.com': qingqing0226
Password for 'https://qingqing0226@github.com': My_Token
注意:我在生成令牌时给予了所有权限,所以我猜没有范围问题。
然后我得到了错误:
remote: Permission to Organization_Name/Repo_Name.git denied to qingqing0226.
fatal: unable to access 'https://github.com/Organization_Name/Repo_Name.git/': The requested URL returned error: 403
我试着推了很多次,总是得到相同的错误信息。似乎密码(令牌)是不正确的,但我将其粘贴在txt文件中检查它,它是正确的(最后没有额外的空间)。
更新:在我使用ssh后,上面的错误消失了。
git config -l
的结果:
user.email=My_Email
user.name=qingqing0226
user.password=My_Token
credential.helper=store
url.git@github.com:.insteadof=https://github.com/
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:Organization_Name/Repo_Name.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
更新:我设置ssh密钥并再次推送,得到新的错误:
The authenticity of host 'github.com (140.82.121.4)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,140.82.121.4' (ECDSA) to the list of known hosts.
ERROR: Permission to Organization_Name/Repo_Name.git denied to qingqing0226.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
似乎我不允许访问repo
最后更新:我修复了它!事实证明,我的ssh、令牌、操作系统或其他任何东西都没有问题。我创建了一个分叉,一切都解决了。
我创建了一个分叉,一切都解决了。
这意味着您试图将(通过HTTPS或SSH,无关紧要)推送到您现在拥有的存储库,或者您不是协作者的存储库。
不同于fork
分支是你管理的存储库的副本。
既然你拥有这个分叉,你可以毫无问题地向它推送。