首页 > 代码库 > git 关联

git 关联

1.登录https://github.com,创建仓库

技术分享

技术分享

2.一般是用ssh,切换到ssh

技术分享

3.本地创建公钥

[root@git xiao]# ssh-keygen -t rsa   # 创建sshGenerating 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@gitThe keys randomart image is:+--[ RSA 2048]----+|          oo*oo+ ||         o =.+o o||          + o....||         . . ... ||        S   ..   ||      .     . .  ||     E .     =   ||        ..  o .  ||       .. ..     |+-----------------+[root@git xiao]# cd /root/.ssh/[root@git .ssh]# lltotal 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 commitsremote: Counting objects: 4, done.remote: Compressing objects: 100% (4/4), done.remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0Unpacking objects: 100% (4/4), done.From github.com:sunmmi/demo * branch            master     -> FETCH_HEADMerge 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 -> masterBranch master set up to track remote branch master from origin.

8.查看

技术分享

 

9.克隆

[root@git tmp]# git clone git@github.com:sunmmi/demo.gitInitialized 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 0Receiving objects: 100% (15/15), 5.59 KiB, done.Resolving deltas: 100% (1/1), done.[root@git tmp]# 

 

git 关联