当我试图将提交推到Github时,我就得到了这个错误:
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/...../...../':
The requested URL returned error: 403
同样的道理,你也可能会遇到类似的错误。例如:
Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
以此类推。
发布于 2022-05-16 10:50:57
要解决这个问题,请执行以下步骤(如果您试图将存储库复制为HTTPS,或者您已经克隆了HTTPS并试图将更改推送到Github):
) git remote -v
在终端上运行这个命令,您将看到如下内容:
origin https://github.com/career-karma-tutorials/ck-git (fetch)
origin https://github.com/career-karma-tutorials/ck-git (push)
2) git remote set-url origin git@github.com:career-karma-tutorials/ck-git
然后运行这个。你会写你的github回购而不是career-karma-tutorials/ck-git
我们这样做是因为我们将使用SSH而不是HTTPS来克隆存储库。
3)ssh-keygen
然后运行这个。你会看到这些:
Enter file in which to save the key (C:\Users\asasa/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your public key has been saved in C:\Users\asasa/.ssh/id_rsa.pub.
The key fingerprint is:
只要按enter键就可以了(如果你愿意的话,你可以做这个安全的事情,但我跳过了)
然后你会看到这样的图像:
The key's randomart image is:
+---[RSA 3542]----+
| =*--B. |
| o+=-=++. |
| o.+---o. |
| . o.+= o. |
| ..= S=. |
| *+ -o. . . |
| .o+. . E |
| ..* . |
| +.* |
+----[SHA126]-----+
4) cat C:\Users\asasa/.ssh/id_rsa.pub.
,然后您将运行这个。(“C:\Users\asasa/..ssh/id_rsa.bar”这部分和第三步的部分是一样的)
运行这个之后,您将看到一个巨大的文本(这是您的钥匙)。复制它,然后转到Github/设置/键,按下新的SSH键,并将您的密钥粘贴到键部分。
然后回到终点站,让你的推或克隆。它会起作用的!)
https://stackoverflow.com/questions/72258032
复制相似问题