在Windows 上安装git ,配置 ssh 到 github
环境 | 版本 |
---|---|
Windows10 | 1803 |
git | 2.17.0 |
1. 下载 windows x64 的git 安装包
2. 安装git
双击git 安装包

选择安装目录

选择安装选项

是否在开始菜单创建文件夹

选择git 默认的编辑器

是否在windows cmd中使用 git

选择openSSL 包

选择换行符

选择git终端模拟器

一些附件选项

开始安装

点击 finish 完成安装

在cmd中查看git版本信息

3. 配置 git 账户名和邮箱
如果你没有github账号,去注册一个吧,如何注册github这里不做介绍。
在cmd中配置账户名和邮箱
~$ git config --global user.email "you@example.com"
~$ git config --global uesr.name "you Name"
4. 配置 ssh
配置ssh 可以免去每次 需要输入密码的麻烦
01. 生成秘钥对 (不设置密码的话,直接三次回车就生成好了)
~$ ssh-keygen -t rsa -C "you@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\用户名/.ssh/id_rsa):
Created directory 'C:\Users\用户名/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
02. 查看生成的公钥
使用文本编辑器打开 用户名/.ssh
文件夹下的 id_rsa.pub
文件
复制文件内容
03. 登录到github上 ,点击头像,然后 Settings
-> 左栏点击 SSH and GPG keys
-> 点击 New SSH key
04. 在title中输入一个名字,在key 文本域中输入你的公钥, 点击 Add SSH Key
05. 验证 key是否正常工作
~$ ssh -T git@github.com
Attempts to ssh to github
当看到
Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access.
表示 ssh 配置完成。
网友评论