Please make sure you have the correct access rightsand the repository e
这是ssh key的问题
首先是否确定设置了username 和 user.email
git config --global user.name "yourName"
git config --global user.email "yourEmail"
之后git输入你的命令
$ ssh-keygen -t rsa -C "your@email.com"(请填你设置的邮箱地址)
之后会出现
Generating public/private rsa key pair. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa
然后一直按enter
然后系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,用记事本打开id_rsa.pub
将全部的内容复制
打开https://github.com/,登陆你的账户,进入设置,ssh设置
新建new ssh,把复制的内容粘贴到里面去
title可以不写
新建成功后
在git命令中输入
ssh -T git@github.com
之后会提示你连接成功
如果出现这个错误:
ssh: connect to host github.com port 22: Connection timed out
在c:/users/username/.ssh文件中新建config文本文件,直接新建txt文件,然后修改成config就行了
然后在config文本文件里输入这些信息
Host github.com
User YourEmail@163.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
保存退出,在使用
ssh -T git@github.com
重新验证,这样就可以了
如果还不能push或者clone的话
加上这句命令
it config remote.origin.url git@github.com:your_username/your_project.git
这样就完全ok了