您的位置:首页 > 运维架构 > Linux

centos学习笔记--github初步使用部分

2016-12-28 22:04 411 查看
安装git【配置获取rsa-key,使本机上可以使用github】

0.github的使用,需要在添加本机地rsa-key。

1.生成rsa key:ssh-keygen -t rsa -b 4096 -C "XXXXX@yeah.net"

出现: Enter file in which to save the key (/root/.ssh/id_rsa):

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:

50:9d:e5:6e:a5:7f:19:52:2a:0e:55:2e:5a:ab:fc:6f XXXXX@yeah.net

The key's randomart image is:

+--[ RSA 4096]----+

| .. o.. |

| . o.o |

| . +.... |

| . +.ooo |

| So o+o . |

| . +.... o|

| o . ...|

| . E . |

| .o. |

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

2.ssh代理设置:eval "$(ssh-agent -s)"

        出现:  Agent pid 3103

3.将ssh代理地rsa-key添加到github帐号中:cat  /root/.ssh/id_rsa.pub

        出现:  ssh-rsa XXXXXXXXXXXXXXXXXXXX字符串XXXXXXXXXX= XXXXX@yeah.net

        将上面那串字符添加到ssh and gpg keys中

4.测试:ssh -T git@github.com

        出现:Enter passphrase for key '/root/.ssh/id_rsa':

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

        表示成功了。

github操作【初始化git配置——创建仓库——添加/删除文件——提交更新——查看日志】

0.配置本地的git账户和邮箱:

        [root@localhost github]# git config --global user.name "XXXXX"

        [root@localhost github]# git config --global user.email "XXXXX@yeah.net"

1.在git网站自己的账户上创建repository(点点点)

2.创建本地库:

        [root@localhost github]# git init

        Initialized empty Git repository in /home/luopan/Documents/github/.git/

3.将本地库和网站库关联:

        [root@localhost github]# git remote add origin git@github.com:XXXXX/image

4.将文件添加到在本地库:

        [root@localhost github]# git add piccs/

5.添加文件注释并提交:

        [root@localhost github]# git commit -m XXX文件注释

6.将文件从本地库提交到网站库:

        [root@localhost github]# git push

        第一回提交到网站库时需要指定branch名:git push --set-upstream origin master

7.上传成功

其他命令:

0.git diff:查看在本地库中修改了什么。修改后还是add->commit->push来进行提交操作

1.git clone git@github.com:XXXXX.git/image.git:下载到本地

2.git log:操作记录

3.git branch:查看分支

4.git checkout -b SSSS:创建新分支

5.git checkout master:切换到master分支

6.git rm 移除文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: