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

安装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 移除文件


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值