我用的是Mac雪豹,刚刚安装了git。
我只是试了
git clone git@thechaw.com:cakebook.git
但这给了我这个错误:
Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我错过了什么?
我也试过做ssh-keygen没有密码,但仍然错误。
同样的错误报告。
修正了使用HTTPS而不是SSH协议的问题。因为我不想为测试PC设置“SSH密钥”。
克隆时将URL更改为HTTPS:
git clone https://github.com/USERNAME/REPOSITORY.git
我的问题有点不同:当添加一个现有的本地回购到远程时,我有URL设置为SSH,通过使用:
git remote add origin ssh://github.com/USERNAME/REPOSITORY.git
要解决这个问题,请将URL重置为HTTPS:
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
顺便说一句,你可以使用命令检查你的URL:
git remote -v
origin https://github.com/USERNAME/REPOSITORY.git (fetch)
origin https://github.com/USERNAME/REPOSITORY.git (push)
希望这能帮助到像我这样的人。: D
视觉指南(Windows)
1 / 2。Git批处理端
1.1. 打开git批处理(下载她)
1.2. 粘贴下面的文本(更改到您的GitHub帐户电子邮件)
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
1.3. 按Enter(接受默认文件位置)
1.4. 单击Enter两次(或设置SSH密钥passphrases - Gitbub passphrases docs)
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
1.5. 键生成:
您的身份信息已保存在/c/Users/user/.ssh/id_rsa…
1.6. 将SSH密钥复制到剪贴板。
$ clip < ~/.ssh/id_rsa.pub
2 / 2。Github网站用户端
在用户设置下
SSH和GPG密钥=>新的SSH密钥:
粘贴步骤1.6中的代码
:完成)
如果有人不想使用SSH,请使用HTTPS:
Github docs: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
我遇到了同样的问题,因为我认为SSH和HTTPS之间的区别是
https://github.com/USERNAME/REPOSITORY.git
ssh: / / github.com/USERNAME/REPOSITORY.git
因此,我从HTTPS更改为SSH,只需将https://更改为SSH:// url的末尾没有任何变化。
但事实是:
https://github.com/USERNAME/REPOSITORY.git
git@github.com:USERNAME/REPOSITORY.git
这意味着我将ssh://github.com/USERNAME/REPOSITORY.git更改为git@github.com:USERNAME/REPOSITORY.git。
愚蠢的错误,但希望能帮助某人!