ubuntu16.04下github的安装和使用

一.检查是否安装了git

sulei@sulei:~$ git version
git version 2.7.4

二.如果没有安装,则使用如下的命令

sudo apt-get install git git-core

三:进行SSH认证

sulei@sulei:~$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
Permission denied (publickey).

验证失败
四.配置信息

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
sulei@sulei:~/.ssh$ git config --list
user.name=shursulei
use.email=1368455669@qq.com

五.
配置完成后,需要创建验证用的公钥,因为git是通过ssh的方式访问资源库的,所以需要在本地创建验证用的文件。使用命令ssh-keygen -C ‘you email address@gmail.com’ -t rsa(注意ssh与-keygen之间没有空格),会在用户目录~/.ssh/下建立相应的密钥文件。
创建完公钥后,需要上传。使用命令cd ~/.ssh进入~/.ssh文件夹,输入gedit id_rsa.pub打开id_rsa.pub文件,复制其中所有内容。

sulei@sulei:~$ ssh-keygen -C "1368455669@qq.com" -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sulei/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/sulei/.ssh/id_rsa.
Your public key has been saved in /home/sulei/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Xy/z8xHEY4xiNynbfM67SpjWKot/gP2AzpIxAyR9TFI 1368455669@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|  ..+E           |
| . o.o        =  |
|  o .      + = * |
|   .      . B + .|
|    .   S  ..o o |
|     + o = .+.+ .|
|      B   =+oo.+ |
|     o o...oo+. o|
|      ...o+. .o=o|
+----[SHA256]-----+

再你注册的邮箱中将复制的内容写进去.
六.再次链接

sulei@sulei:~/.ssh$ ssh -T git@github.com
Hi shursulei! You've successfully authenticated, but GitHub does not provide shell access.

七.创建版本库并初始化

sulei@sulei:~$ mkdir learngit
sulei@sulei:~$ cd learngit/
sulei@sulei:~/learngit$ pwd
/home/sulei/learngit
sulei@sulei:~/learngit$ git init
初始化空的 Git 仓库于 /home/sulei/learngit/.git/

言归正传,现在我们编写一个readme.txt文件,内容如下:

sulei@sulei:~/learngit$ gedit readme.txt
内
Git is a version control system.
Git is free software.

提交.但是出错

sulei@sulei:~/learngit$ git add readme.txt 
sulei@sulei:~/learngit$ git commit -m "wrote a readme file"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'sulei@sulei.(none)')
sulei@sulei:~/learngit$ git config --global user.name "shursulei"
sulei@sulei:~/learngit$ git config --global user.email "1368455669@qq.com"
修改后如上:
sulei@sulei:~/learngit$ git commit -m "wrote a readme file"
[master (根提交) cf8d9c1] wrote a readme file
 1 file changed, 2 insertions(+)
 create mode 100644 readme.txt

参考地方:

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013743858312764dca7ad6d0754f76aa562e3789478044000
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值