一、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上查看上传的内容