一. git安装及github账号注册
1. git 安装
下载地址:
https://git-for-windows.github.io/
2.github创建账号
https://github.com/
二. git初始化配置
Git安装成功后,打开Git Bash
1.设置user.name和user.email
$ git config --global user.name "你的用户名"
$ git config --global user.email "你的邮箱"
2.生成SSH秘钥
当前用户目录下执行以下语句,然后查找.ssh文件夹,在/home/acer(我当前用户的用户名)/.ssh,也可以用命令find -name ".ssh"
$ ssh-keygen -t rsa -C "你的邮箱"
如果不设置密码,连续三个回车,最终.ssh文件夹下生成两个文件:
id_rsa
id_rsa.pub
3.添加秘钥
.ssh文件目录下执行
$ ssh-add id_rsa
如果报错:Could not open a connection to your authentication agent.
则先执行:
$ ssh-agent bash
之后再执行:
$ ssh-add id_rsa
则执行结果:
Identity added: id_rsa (id_rsa)
4. 登录github,配置ssh
点击用户头像位置,选择settings
左侧选择 SSH and GPG keys
选择 New SSH key
title: 自己起个名字
key: 复制你本地.ssh文件目录下id_rsa.pub的内容
点击 Add SSH key
5.测试配置结果
ssh -T git@github.com
会看到:
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?
选择 yes
最终会提示:
Hi 你的用户名! You've successfully authenticated, but GitHub does not provide shell access.
至此,说明配置成功~~
对于删除repositories
进入setting后,拉到最下面