git和github的使用

一、git的安装
yum install -y git
二、创建私钥
ssh-keygen -t rsa -C "981240760@qq.com"
一直默认执行回车
cd /root/.ssh
拷贝id_rsa.pub的内容添加到下图的github
在这里插入图片描述
测试是否成功
如果是第一次的会提示是否continue,输入yes就会看到:You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。

[root@localhost .ssh]# ssh -T git@github.com
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi shanwu888! You've successfully authenticated, but GitHub does not provide shell access.

三、设置用户名称和邮箱

[root@localhost .ssh]# git config --global user.name "shanwu"
[root@localhost .ssh]# git config --global user.email "981240760@qq.com"

四、git的简单使用
首先clonegithub的仓库,再添加文件上传上去

[root@localhost python]# git clone git@github.com:shanwu888/studypy.git
Cloning into 'studypy'...
Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
warning: You appear to have cloned an empty repository.
[root@localhost studypy]# echo "#studypy">>README.md
[root@localhost studypy]# git add !$
git add README.md
[root@localhost studypy]# ll
total 4
-rw-r--r--. 1 root root 9 Nov 15 12:52 README.md
[root@localhost studypy]# git commit -m "first"
[master (root-commit) b6b84bf] first
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
[root@localhost studypy]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 212 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/shanwu888/studypy/pull/new/master
remote: 
To git@github.com:shanwu888/studypy.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

五、在git上查看上传的内容
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值