您的位置:首页 > 编程语言

ubuntu14.04下github的安装与使用

2015-05-18 14:04 225 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: