windows git配置

安装

下载地址:https://git-scm.com/downloads

image-20200213102140692

image-20200213102203600

具体可以参考:https://blog.csdn.net/qq_32786873/article/details/80570783
一句话总结:双击->自定义目录->一直next到底

配置github

配置用户名、邮箱

//此处name可修改也不是用于登录github的登录名
git config --global user.name "username"
//github邮箱
git config --global user.email "email"

查看用户名邮箱

git config --global user.name
git config --global user.email

生成公钥

ssh-keygen -t rsa -C "[email protected]"

按三次回车
image-20200213102811969

看到保存的路径

cd ~/.ssh
# 公钥的内容在id_rsa.pub
cat .\id_rsa.pub

复制id_rsa.pub中的内容,在github设置中新建ssh key,title能够为空

image-20200213103038956

测试ssh

ssh -T [email protected]

image-20200213104021665

如上图,报错如下

ssh: connect to host github.com port 22: Connection timed out

可能存在的原因 github的公钥配置错误了,可是我反复尝试了多次,还是有问题,原因可能是端口被占用,终于找到了解决方案:

在~/.ssh 下,即公钥的统计目录中新建config文件,内容如下

Host github.com

User git

Hostname ssh.github.com

PreferredAuthentications publickey

IdentityFile ~/.ssh/id_rsa

Port 443

image-20200213104335452

再次ssh -T [email protected],终于成功了

image-20200213104437463

发布了515 篇原创文章 · 获赞 2255 · 访问量 211万+

猜你喜欢

转载自blog.csdn.net/dataiyangu/article/details/104317400
今日推荐