ubuntu14.04下github的安装与使用

1、申请一个github的账户(申请网址为:http://github.com)

2、安装git

$sudo apt-get install git

3、生成密钥对,这样项目可以push到github上

$ssh-keygen -t rsa -C "邮箱"

4、将.ssh/id_rsa.pub复制到github网站上去

Generating public/private rsa key pair.

Enter file in which to save the key (/home/zcq/.ssh/id_rsa):     #一般直接回车,使用默认的路径。其中.ssh/id_rsa是隐藏文件

Enter passphrase (empty for no passphrase):                           #输入密码

Enter same passphrase again:

Your identification has been saved in /home/zcq/.ssh/id_rsa.
Your public key has been saved in /home/zcq/.ssh/id_rsa.pub.

The key fingerprint is:

.................

.................


$cat /home/zcq/.ssh/id_rsa.pub                    #找到公钥,并将其复制到github网站的SSH keys中去(settings-->SSH keys)

                                                                          #Title名字任取,key为刚才复制的公钥

5、为了方便,设置ssh不输入口令

$eval `ssh-agent`

$ssh-add

Enter passphrase for /home/zcq/.ssh/id_rsa:                       #输入密码

6、测试是否可以联通到github

$ssh git@github.com

如果配置正确,则会显示

Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
7、设置git全局用户配置

$git config --global user.name "xxx"

$git cofig --global user.email 邮箱

8、使用github

(1)新建一个仓库(repository)

填写好仓库名称(比如first_project),简单写一些描述,并勾选上初始化仓库README

(2)克隆版本库

$git clone git@github.com:xxx/first_project.git           #在根目录下

$ cd first_project

$ touch index.html

$ echo "this is git test" > index.html

$ git add index.html

$ git commit -m "add index.html"

$ git push origin master

(3)在github仓库中就可以看到刚刚加入的index.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值