github的安装与简单使用

客户端安装

使用yum命令下载资源包,直接安装

1
[root@localhost ~]# yum install git git-gui

注册github

浏览器中打开github.com根据提示注册

生成公钥
1
[root@localhost ~]# ssh-key -t rsa -c "github注册邮箱地址"
导入公钥

打开根目录的.ssh文件夹下id_rsa.pub文件,复制其中的key,然后在github右上角点击设置按钮,单击左侧菜单栏的ssh key项,点击add ssh key添加公钥,在弹出的dialog中,key栏粘贴上刚才复 制的key,title随意填写。

帐号配置
1
2
[root@localhost ~]# git config --global user.name "用户名"
[root@localhost ~]# git config --global user.email github注册邮箱地址
校验

配置好后进行校验, 如果返回You‘ve successfully authenticated,but Github does not provide shell access.提示,则表示校验通过

1
[root@localhost ~]# ssh -t git@github.com

创建github仓库

登录github进入管理页面,点击Repositories,然后New一个新的库如blog,打开创建的库,在右下角会有一个仓库地址的url,是作为本地项目提交的地址,复制其中的ssh clone url:git@github.com:用户名/blog.git。

创建项目目录并初始化
1
2
3
[root@localhost ~]# mkdir blog
[root@localhost blog]# cd blog
[root@localhost blog]# git init
提交此文件到本地
1
2
[root@localhost blog]# git add .
[root@localhost blog]# git commit -m "说明"
提交到github
1
2
[root@localhost blog]# git remote add origin  "ssh clone url"
[root@localhost blog]# git push origin master
删除origin连接和更新文件到本地命令
1
2
[root@localhost blog]# git remote rm origin
[root@localhost blog]# git pull origin master

—EOF—