1、github.com 注冊(cè)賬戶
2怠益、github 上創(chuàng)建倉(cāng)庫(kù)
3仪搔、本地服務(wù)器生成 ssh 公鑰
[root@qfedu.com ~]# ssh-keygen -t rsa -C 'meteor@163.com' # 郵箱要與github上注冊(cè)的相同
[root@qfedu.com ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVThfq4brrlsPGtAknVB0TLPx+7Dd3qlxTbSIrUOsGC5Y8JuNqVTlIntZB4oNj8cSQrWvec9CKm0a8o7WwaJIiqpxurz+YpQHP2KbapftKIxsX4hPf/z+p0El1U6arQa35/xmNsq+cJLH/bDdRG+EMDhuCBmjVZOlLj/hEdeIT6s56AnnCkaWoF+sq58KCF7Tk54jRbs/YiyE4SN7FuA70r+07sA/uj0+lmuk4E190KtQUELhjX/E9stivlqiRhxnKvVUqXDywsjfM8Rtvbi4Fg9R8Wt9fpd4QwnWksYUoR5qZJFYXO4hSZrUnSMruPK14xXjDJcFDcP2eHIzKgLD1 meteor@163.com
4、 github 添加 ssh 公鑰
復(fù)制以上的公鑰蜻牢,在 github 中添加ssh key
5烤咧、測(cè)試連接
[root@qfedu.com ~]# yum install git
........
[root@qfedu.com ~]# ssh -T git@qfedu.comhub.com
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5: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 meteor! You've successfully authenticated, but GitHub does not provide shell access.
[root@qfedu.com ~]#
6偏陪、連接遠(yuǎn)程倉(cāng)庫(kù)(創(chuàng)建一個(gè)測(cè)試存儲(chǔ)庫(kù))
git 初始化,然后做第一個(gè)基本的git操作(需要在github上創(chuàng)建存儲(chǔ)庫(kù))
# 在 github 網(wǎng)站新建一個(gè)倉(cāng)庫(kù)煮嫌,命名為linux
~~~
[root@qfedu.com ~]# cd /opt
[root@qfedu.com ~]# mkdir linux
[root@qfedu.com ~]# cd linux
~~~
# git 初始化笛谦,然后做第一個(gè)基本的git操作(需要在github上創(chuàng)建存儲(chǔ)庫(kù))
[root@qfedu.com ~]# git init
[root@qfedu.com ~]# touch README
[root@qfedu.com ~]# git add README
[root@qfedu.com ~]# git commit -m 'first commit'
[root@qfedu.com ~]# git remote add origin git@qfedu.comhub.com:userhub/linux.git
~~~
# 若出現(xiàn)origin已經(jīng)存在的錯(cuò)誤,刪除origin
[root@qfedu.com linux]# git remote rm origin
# 現(xiàn)在繼續(xù)執(zhí)行push到遠(yuǎn)端
~~~
[root@qfedu.com linux]# git remote add origin git@qfedu.comhub.com:userhub/linux.git
[root@qfedu.com linux]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 205 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@qfedu.comhub.com:fakehydra/linux-.git
* [new branch] master -> master
分支 master 設(shè)置為跟蹤來(lái)自 origin 的遠(yuǎn)程分支 master昌阿。
# 注意
# 設(shè)置存儲(chǔ)庫(kù)鏈接
[root@qfedu.com ~]# git remote set-url origin git@qfedu.comhub.com:userhub/linux.git
# 如果 push 失敗饥脑,合并分支到 master 再 push
[root@qfedu.com ~]# git pull --rebase origin master