1、安装Git
1 | yum -y install git |
---|
2、创建Githup账号,官网
3、生成ssh key
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [root@blog_site .ssh]# ssh-keygen -t rsa Generating public/private rsa key pair. 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: SHA256:wcI81DO4V/IHAPWEnna8VFNbaJPvkg5VynEoUPT8GqQ root@blog_site The key's randomart image is: +---[RSA 2048]----+ | o=ooo+o..+.| | +..*oo +oBoo| | =ooO.o ==B | | .o=.= .o+..| | oSo oE..o.| | . . oo.| | o.. | | . | | | +----[SHA256]-----+ 一路回车 |
---|
4、将公钥添加到GitHup上
5、验证
1 2 3 4 5 6 7 | [root@blog_site Blog_sit]# ssh -T git@github.com The authenticity of host 'github.com (192.30.253.112)' 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,192.30.253.112' (RSA) to the list of known hosts. Hi devilf! You've successfully authenticated, but GitHub does not provide shell access. |
---|
6、创建一个目录作为本地仓库
1 2 3 4 | mkdir /Blog_site git init git remote add origin git@github.com:devilf/Blog_site.git git push origin master |
---|
7、从GitHup克隆项目到本地
1 2 3 | [root@blog_site Blog_sit]# git clone https://github.com/devilf/Blog_site.git Cloning into 'Blog_site'... warning: You appear to have cloned an empty repository. |
---|
本地的版本不是最新的时候,可以使用命令更新
1 | git fetch origin |
---|
把更新的内容合并到本地分支:
1 2 | git merge origin/master git pull origin master #拉取最新版本并自动合并 |
---|