git 的使用(1)-linux上的配置

Ubuntu Linux 下 git 的创建和配置

1. 创建github 账号:

网站: https://github.com/

账号密码自己填。Ok

2. 进入Ubuntu命令编辑器。

1)生成SSH keys

  ssh-keygen -t rsa -C "yangyi@sina.cn"  

root@yangyi:~# ssh-keygen -t rsa -C 'yangyi@sina.cn'  #这里填你的注册邮箱

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):   #回车就可以,默认的路径

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase): #输入密码,不一定要是注册密码

Enter same passphrase again: #重复输入密码,看不见的

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

a0:95:33:24:26:ca:b7:ed:c2:95:97:48:d4:e9:4f:89 yangyi@sina.cn

The key's randomart image is:

+--[ RSA 2048]----+

|  . o.o .        |

|.. o.o +         |

|.. . .B . .      |

|  . +ooE.o       |

|   ..= oS        |

|  . o .  .       |

|   o .           |

|    .            |

|                 |

+-----------------+

root@yangyi:~# 


2)复制key github网站

打开,刚才生成的密钥:


全部复制,进入github 网站,点击Account settings


点击SSH keys


Add SSH key


输入,刚才复制的密钥,到key 框中,title 随便填就可以了。

点击 Add key ,会跳转到确认密码页面:


Confirm password 即可。

Ok .ssh key 添加完成:


3)  密钥验证

ssh -T git@github.com  
输入 yes  即可。

root@yangyi:~# ssh -T git@github.com

The authenticity of host 'github.com (204.232.175.90)' can't be established.

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.

Are you sure you want to continue connecting (yes/no)? Yes  #输入yes

Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.

Enter passphrase for key '/root/.ssh/id_rsa':  #输入创建密钥时的密码。

Hi iyangyi! You've successfully authenticated, but GitHub does not provide shell access.

# 出现这一句,代码验证成功。


3. 安装git

Ubuntu 安装git 很简单:

yangyi@yangyi:~$ sudo apt-get install git # 自动安装好了就可以了。

4. 配置邮箱和用户名:

https://help.github.com/articles/set-up-git#platform-linux

yangyi@yangyi:~$ git config --global user.name 'yangyi'

yangyi@yangyi:~$ git config --global user.email 'yangyi@sina.cn'

yangyi@yangyi:~$ git init

Initialized empty Git repository in /home/yangyi/.git/

Ok 安装和配置完毕。


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值