标签:
1.登录https://github.com,创建仓库
2.一般是用ssh,切换到ssh
3.本地创建公钥
[root@git xiao]# ssh-keygen -t rsa # 创建ssh 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: 95:f4:e9:75:81:24:0d:29:5d:35:8e:eb:96:a3:a2:81 root@git The key‘s randomart image is: +--[ RSA 2048]----+ | oo*oo+ | | o =.+o o| | + o....| | . . ... | | S .. | | . . . | | E . = | | .. o . | | .. .. | +-----------------+ [root@git xiao]# cd /root/.ssh/ [root@git .ssh]# ll total 12 -rw-------. 1 root root 1671 Jun 14 11:06 id_rsa -rw-r--r--. 1 root root 390 Jun 14 11:06 id_rsa.pub -rw-r--r--. 1 root root 394 Jun 14 08:55 known_hosts [root@git .ssh]# cat id_rsa.pub # 查看公钥 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApcGI83K97/yyaiUzPm+CevHWj+84XXCFdovPC8X6Uzjwylu/lcE2YixRdj2WZPDHoJDrRP4WiS1sIDKU7aTG+lqPHEEbN5MClSdTwTnFPXPWJo2BHD3a1nB86feOWgt+rErsYq8Rv4wgJEsEP78aHlz3JAPWooNs/K6hvXpN8fvheDnvX9CARsG7pXu+IAydHWwXUsfyN8uzlqHKidfwY5WZq3a/K/BPe0Z+qhZM8NfMtYcHNPWLaYBA4WEaEvTenxlWjZc1VEMjyLfoV26iejOdTuCLCyHKQXfqVkn3oZEMPaueMUMDX50lhAla2UB+a7gOu1mdlGxxoJkDW7+C3Q== root@git
4.把服务器的公钥配置到github
5.本地仓库与远程仓库进行关联地址
6.关联
[root@git .ssh]# cd /root/xiao/ # 切换到工作区目录 [root@git xiao]# git remote add origin git@github.com:sunmmi/demo.git # 进行关联 [root@git xiao]# cat .git/config # 查看 [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = git@github.com:sunmmi/demo.git fetch = +refs/heads/*:refs/remotes/origin/*
7.拉取到本地,然后推上去
[root@git xiao]# git pull origin master # 拉取 Warning: Permanently added the RSA host key for IP address ‘192.30.253.113‘ to the list of known hosts. warning: no common commits remote: Counting objects: 4, done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (4/4), done. From github.com:sunmmi/demo * branch master -> FETCH_HEAD Merge made by recursive. .gitignore | 89 ++++++++++++++++++++++++++ LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 290 insertions(+), 0 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE [root@git xiao]# ls -a #查看 . .. deploy.sh .git .gitignore LICENSE readme.txt [root@git xiao]# git push -u origin master # 推上去 Counting objects: 12, done. Compressing objects: 100% (7/7), done. Writing objects: 100% (11/11), 1.01 KiB, done. Total 11 (delta 0), reused 0 (delta 0) To git@github.com:sunmmi/demo.git bb4826e..2d68e8d master -> master Branch master set up to track remote branch master from origin.
8.查看
9.克隆
[root@git tmp]# git clone git@github.com:sunmmi/demo.git Initialized empty Git repository in /tmp/demo/.git/ remote: Counting objects: 15, done. remote: Compressing objects: 100% (11/11), done. remote: Total 15 (delta 1), reused 11 (delta 0), pack-reused 0 Receiving objects: 100% (15/15), 5.59 KiB, done. Resolving deltas: 100% (1/1), done. [root@git tmp]#
标签:
原文地址:http://www.cnblogs.com/sunmmi/p/5847713.html