对本地计算机里面安装的GIt进行设置.
通过在终端输入:
mj@mj-OMEN-by-HP-Laptop-15-dc0xxx:~$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
mj@mj-OMEN-by-HP-Laptop-15-dc0xxx:~$ git --version
git version 2.7.4
查看是否已经安装了Git
1,设置姓名和邮箱
$git config --global user.name "Firstname Lastname"
$git config --global user.email "youremial@example.com"
2,提高名输出的可读性
$git config --global color.ui auto
3,可以通过一下命令查看config设置
$git config --list
user.name=Firstname Lastname
user.email=youremial@example.com
color.ui=auto
4,设置SSH秘钥
$ ssh-keygen -t -C "youremial@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key
(/home/mj.ssh/id_rsa):按回车键
Enter passphrase(empty for no passphrase):输入密码
Enter same passphrase again:再次输入密码
输入以后出现一下结果
Your identification has been saved in /home/mj/.ssh/id_rsa.
Your public ket has been saved in /home/mj/.ssh/id)rsa.pub.
The ket fingerprint is:
fingerprint值 youremial@example.com
The key's randomart image is:
略
id_rsa:私有秘钥
id_rsa.pub: 公开秘钥
5,添加公开秘钥
在GitHub账户里面设置里 SSH and GPG keys 里面点击New SSH key
Title里面的内容自己填一个描述自己秘钥的
key里面的东西填写地id_rsa.pub里面的内容.
id_rsa.pub的内容查看方法:
$cat ~/.ssh/id_rsa.pub
ssh-rsa 公开秘钥的内容 youremial@example.com
将ssh-rsa 公开秘钥的内容 youremial@example.com
这个全部内容复制到key里面
添加成功后会收到一封提示邮件.
6,用手中的私人秘钥与Github进行认证和通信
$ssh -T git@github.com
Hi hirocastest! Your successfully 略
即表示成功.
参考:Github入门与实践