当前位置:   article > 正文

ssh免密登陆与git详解_git@192.168.0.188's password:

git@192.168.0.188's password:

目录

ssh免密登陆

利用root账号密码登录ssh服务端

利用root账号免密登录ssh服务端

利用非root账号免密登录ssh服务端

处理git用户的shell为git-shell

出现的问题

git详细教程

搭建git本地服务器

配置ssh远程访问

创建git本地仓库

git clone与git pull的区别 

git如何拉取指定分支的代码

git fetch与git merge


ssh免密登陆


参考文章:http://blog.itpub.net/70017844/viewspace-2909916/
linux系统CentOS Linux release 7.9.2009 (Core)
zabbix-server    192.168.220.128
zabbix-proxy     192.168.220.108

利用root账号密码登录ssh服务

  1. 1.zabbix-server开启ssh服务
  2. [root@zabbix-server ~]# rpm -qf `which ssh`
  3. openssh-clients-7.4p1-21.el7.x86_64
  4. [root@zabbix-server ~]# rpm -qf `which sshd`
  5. openssh-server-7.4p1-21.el7.x86_64
  6. [root@zabbix-server ~]# systemctl status sshd
  7. ● sshd.service - OpenSSH server daemon
  8.    Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
  9.    Active: active (running) since Thu 2023-04-20 22:35:42 EDT; 4h 27min ago
  10.      Docs: man:sshd(8)
  11.            man:sshd_config(5)
  12.  Main PID: 2563 (sshd)
  13.    CGroup: /system.slice/sshd.service
  14.            └─2563 /usr/sbin/sshd -D
  15. ........
  16. 2.zabbix-proxy账号密码登录zabbix-server
  17. [root@zabbix-proxy ~]# ssh root@192.168.220.128
  18. The authenticity of host '192.168.220.128 (192.168.220.128)' can't be established.
  19. ECDSA key fingerprint is SHA256:WWjD+PCmlUmq2jJJF32DbaHWE32uVKO/h66k32jf9Ns.
  20. ECDSA key fingerprint is MD5:92:ea:a5:d4:a6:ad:10:de:97:a5:bd:4f:67:ce:87:d6.
  21. Are you sure you want to continue connecting (yes/no)? yes ####输入yes后会添加一条192.168.220.128的信息到客户端~/.ssh下的known_hosts文件
  22. Warning: Permanently added '192.168.220.128' (ECDSA) to the list of known hosts.
  23. root@192.168.220.128's password: 
  24. Last login: Thu Apr 20 23:34:23 2023 from 192.168.220.1
  25. [root@zabbix-server ~]
  26. 客户端
  27. [root@zabbix-proxy ~]# cat known_hosts
  28. 192.168.220.125 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBE7++JhhOslmX5T1/B2knqMR84TycWTSLUyQ2HYpoKMnKtVm2oqDhQuGksf19KjFHYxB7jFT4wpkAHGBwst8RtY=
  29. 192.168.220.128 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBE7++JhhOslmX5T1/B2knqMR84TycWTSLUyQ2HYpoKMnKtVm2oqDhQuGksf19KjFHYxB7jFT4wpkAHGBwst8RtY=

利用root账号免密登录ssh服务端

  1. ###手动复制客户端公钥到服务端authorized_keys文件内实现免密登录的方式有时候不好用,强烈建议使用ssh-copy-id命令
  2. [root@zabbix-proxy ~]# ssh-keygen -t rsa
  3. Generating public/private rsa key pair.
  4. Enter file in which to save the key (/root/.ssh/id_rsa): 
  5. Enter passphrase (empty for no passphrase): 
  6. Enter same passphrase again: 
  7. Your identification has been saved in /root/.ssh/id_rsa.
  8. Your public key has been saved in /root/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. SHA256:Hb3aqAwQvPhc4nL1Tf8beXzvL4coAMrtMn7Q4dgVPbc root@zabbix-proxy
  11. The key's randomart image is:
  12. +---[RSA 2048]----+
  13. |         .       |
  14. |   .    . o..    |
  15. |    o    ..o..   |
  16. |   . oo .. .E.   |
  17. |  ..+Bo+S o .    |
  18. |   +===..o =   o |
  19. |  . =o. ..+ o.o.+|
  20. |   oo oo .. ..oo+|
  21. |   ..+  o  .  o==|
  22. +----[SHA256]-----+
  23. 将/root/.ssh/id_rsa.pub的内容复制到服务端zabbix-server下的/root/.ssh/authorized_keys文件内        ###将ssh客户端公钥复制到服务端
  24. [root@zabbix-proxy .ssh]# ssh root@192.168.220.128       ###客户端实现免密登录
  25. Last login: Fri Apr 21 03:05:43 2023 from 192.168.220.108
  26. [root@zabbix-server ~]# 
  27. 或者通过公钥拷贝指令# ssh-copy-id username@ip
  28. ###ssh-copy-id命令会在username用户家目录下创建.ssh/authorized_keys文件,文件内容为免密登录客户机的公钥信息
  29. [root@zabbix-proxy ~]# ssh-keygen -t rsa
  30. Generating public/private rsa key pair.
  31. Enter file in which to save the key (/root/.ssh/id_rsa): 
  32. Enter passphrase (empty for no passphrase): 
  33. Enter same passphrase again: 
  34. Your identification has been saved in /root/.ssh/id_rsa.
  35. Your public key has been saved in /root/.ssh/id_rsa.pub.
  36. The key fingerprint is:
  37. SHA256:Hb3aqAwQvPhc4nL1Tf8beXzvL4coAMrtMn7Q4dgVPbc root@zabbix-proxy
  38. The key's randomart image is:
  39. +---[RSA 2048]----+
  40. |         .       |
  41. |   .    . o..    |
  42. |    o    ..o..   |
  43. |   . oo .. .E.   |
  44. |  ..+Bo+S o .    |
  45. |   +===..o =   o |
  46. |  . =o. ..+ o.o.+|
  47. |   oo oo .. ..oo+|
  48. |   ..+  o  .  o==|
  49. +----[SHA256]-----+
  50. [root@zabbix-proxy .ssh]# ssh-copy-id root@192.168.220.128
  51. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
  52. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  53. /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  54. root@192.168.220.128's password:         #此处输入密码登录服务端
  55. Number of key(s) added: 1
  56. Now try logging into the machine, with:   "ssh 'root@192.168.220.128'"
  57. and check to make sure that only the key(s) you wanted were added.
  58. [root@zabbix-proxy .ssh]# ssh 'root@192.168.220.128'
  59. Last login: Fri Apr 21 03:20:32 2023 from 192.168.220.108
  60. [root@zabbix-server ~]# 
  61. [root@zabbix-server ~]# 

利用非root账号免密登录ssh服务端

  1. ssh服务端
  2. [root@zabbix-server .ssh]# useradd -m git
  3. [root@zabbix-server .ssh]# passwd git
  4. Changing password for user git.
  5. New password: 
  6. Retype new password: 
  7. passwd: all authentication tokens updated successfully.
  8. [root@zabbix-server .ssh]# mkdir -p /home/git/.ssh/
  9. [root@zabbix-server .ssh]# vi /home/git/.ssh/authorized_keys    ###将ssh客户端公钥添加到服务端/home/git/.ssh/authorized_keys文件内
  10. [root@zabbix-server .ssh]# chown -R git. /home/git/.ssh/        #重点在修改文件的属性和权限,否则ssh git@192.168.220.128,任然会提示输入git用户密码
  11. [root@zabbix-server .ssh]# chmod -R 700 /home/git/.ssh/
  12. ssh客户端通过非root用户连接服务端
  13. [root@zabbix-proxy .ssh]# ssh git@192.168.220.128
  14. git@192.168.220.128's password: 
  15. [git@zabbix-server ~]$ 
  16. [git@zabbix-server ~]$ 
  17. 或者通过公钥拷贝指令ssh-copy-id
  18. ssh服务端
  19. [root@zabbix-server .ssh]# useradd -m git
  20. [root@zabbix-server .ssh]# passwd git
  21. Changing password for user git.
  22. New password: 
  23. Retype new password: 
  24. passwd: all authentication tokens updated successfully.
  25. [root@zabbix-server git]# ls -l /home/git/.ssh/authorized_keys    #git用户目录下没有此文件下面用ssh-copy-id命令生成
  26. ls: cannot access /home/git/.ssh/authorized_keys: No such file or directory
  27. ssh客户端通过非root用户连接服务端
  28. [root@zabbix-proxy ~]# ssh-keygen -t rsa
  29. Generating public/private rsa key pair.
  30. Enter file in which to save the key (/root/.ssh/id_rsa): 
  31. Enter passphrase (empty for no passphrase): 
  32. Enter same passphrase again: 
  33. Your identification has been saved in /root/.ssh/id_rsa.
  34. Your public key has been saved in /root/.ssh/id_rsa.pub.
  35. The key fingerprint is:
  36. SHA256:Hb3aqAwQvPhc4nL1Tf8beXzvL4coAMrtMn7Q4dgVPbc root@zabbix-proxy
  37. The key's randomart image is:
  38. +---[RSA 2048]----+
  39. |         .       |
  40. |   .    . o..    |
  41. |    o    ..o..   |
  42. |   . oo .. .E.   |
  43. |  ..+Bo+S o .    |
  44. |   +===..o =   o |
  45. |  . =o. ..+ o.o.+|
  46. |   oo oo .. ..oo+|
  47. |   ..+  o  .  o==|
  48. +----[SHA256]-----+
  49. [root@zabbix-proxy ~]# ssh-copy-id git@192.168.220.128
  50. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
  51. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  52. /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  53. git@192.168.220.128's password:         #输入git密码
  54. Number of key(s) added: 1
  55. Now try logging into the machine, with:   "ssh 'git@192.168.220.128'"
  56. and check to make sure that only the key(s) you wanted were added.
  57. [root@zabbix-proxy ~]# ssh git@192.168.220.128
  58. Last login: Fri Apr 21 04:20:12 2023 from 192.168.220.108
  59. [git@zabbix-server ~]$ 
  60. ssh服务端
  61. [root@zabbix-server ~]# ls -l /home/git/.ssh/authorized_keys        ##可以看到公钥被拷贝到authorized_keys文件内
  62. -rw------- 1 git git 399 Apr 21 04:19 /home/git/.ssh/authorized_keys

处理git用户的shell为git-shell

  1. # rpm -qf `which git-shell` #git-shell属于git软件包
  2. git-1.8.3.1-25.el7_9.x86_64
  3. 在Git用作仓库的时候我们可以将默认ssh登录shell改为git-shell,这个git提供的shell程序,一旦登录会自动秒退  #为了安全考虑我们需要禁用ssh登录到我们的shell,防止别人登录到shell之后对我们的电脑做增删改
  4. ssh服务器
  5. [root@zabbix-server git]# chsh -s `which git-shell` git
  6. Changing shell for git.
  7. chsh: Warning: "/usr/bin/git-shell" is not listed in /etc/shells.
  8. Shell changed.
  9. ssh客户端
  10. [root@zabbix-proxy ~]# ssh git@192.168.220.128
  11. git@192.168.220.128's password: 
  12. Last login: Fri Apr 21 04:23:57 2023 from 192.168.220.108
  13. fatal: Interactive git shell is not enabled.
  14. hint: ~/git-shell-commands should exist and have read and execute access.
  15. Connection to 192.168.220.128 closed.
  16. [root@zabbix-proxy ~]# 

出现的问题

问题1:由于用户git在服务器端的 shell 为 git-shell,在使用 ssh-copy-id 的时候报错:
[root@zabbix-proxy test]# ssh-copy-id git@192.168.220.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
git@192.168.220.128's password: 
fatal: unrecognized command 'exec sh -c 'cd ; umask 077 ; mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi''
解决办法
[root@zabbix-proxy .ssh]# scp /root/.ssh/id_rsa.pub root@192.168.220.128:/home/git/.ssh/authorized_keys   #确保ssh服务器/home/git/.ssh/目录存在,scp是ssh的文件复制命令   
id_rsa.pub                                                     100%  399   373.5KB/s   00:00   
[root@zabbix-proxy .ssh]# ssh root@192.168.220.128
Last login: Fri Apr 21 04:12:25 2023 from 192.168.220.108
[root@zabbix-server ~]# cd /home/git/
[root@zabbix-server git]# chown -R git. .ssh
[root@zabbix-server git]# chmod -R 700 .ssh/
[root@zabbix-server git]# ll /home/git/.ssh/
total 4
-rwx------ 1 git git 399 Apr 21 05:35 authorized_keys
 

git详细教程

Git 分支管理 | 菜鸟教程
关于Git这一篇就够了_17岁boy想当攻城狮的博客-CSDN博客
Git简明指南git 简明指南

搭建git本地服务器

环境
[root@zabbix-server ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)
zabbix-server    192.168.220.128
zabbix-proxy     192.168.220.108
分别已安装软件  yum install git ssh -y;service ssh start 

配置ssh远程访问

  1. zabbix-server服务端
  2. [root@zabbix-server ~]# useradd -m git
  3. [root@zabbix-server ~]# passwd git       #给git用户设置密码
  4. Changing password for user git.
  5. New password: 
  6. Retype new password: 
  7. passwd: all authentication tokens updated successfully.
  8. zabbix-proxy客户端
  9. [root@zabbix-proxy ~]# ssh-keygen -t rsa
  10. Generating public/private rsa key pair.
  11. Enter file in which to save the key (/root/.ssh/id_rsa): 
  12. Enter passphrase (empty for no passphrase): 
  13. Enter same passphrase again: 
  14. Your identification has been saved in /root/.ssh/id_rsa.
  15. Your public key has been saved in /root/.ssh/id_rsa.pub.
  16. The key fingerprint is:
  17. SHA256:fmDBtjmOjnHxy/HOhtT4+PcvyZ91533TbelGyo8n5Sw root@zabbix-proxy
  18. The key's randomart image is:
  19. +---[RSA 2048]----+
  20. |                 |
  21. |       .         |
  22. |        +        |
  23. |       . +       |
  24. |      . So       |
  25. |       Boo.    o |
  26. |    . o.=+. ..*.B|
  27. |     = .o*o .E=O@|
  28. |    . . o+=. oOOB|
  29. +----[SHA256]-----+
  30. [root@zabbix-proxy ~]# ssh-copy-id git@192.168.220.128
  31. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
  32. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  33. /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  34. git@192.168.220.128's password: 
  35. Number of key(s) added: 1
  36. Now try logging into the machine, with:   "ssh 'git@192.168.220.128'"
  37. and check to make sure that only the key(s) you wanted were added.
  38. [root@zabbix-proxy ~]# ssh 'git@192.168.220.128'                  #免密访问
  39. Last failed login: Fri Apr 21 05:05:04 EDT 2023 from 192.168.220.108 on ssh:notty
  40. There was 1 failed login attempt since the last successful login.
  41. [git@zabbix-server ~]$ 
  42. zabbix-server服务端
  43. [root@zabbix-server .ssh]# chown -R git. /home/git/.ssh/
  44. [root@zabbix-server .ssh]# chmod -R 700 /home/git/.ssh/
  45. [root@zabbix-server .ssh]# chsh -s `which git-shell` git               #修改git用户的shell,防止客户机ssh通过git用户登录服务器修改文件
  46. Changing shell for git.
  47. chsh: Warning: "/usr/bin/git-shell" is not listed in /etc/shells.
  48. Shell changed.

创建git本地仓库

  1. zabbix-server服务端
  2. 创建仓库存放路径并设置所属用户为git,路径可任意起名,这里叫gitrepo。
  3. [root@zabbix-server .ssh]# mkdir -p /home/git/gitrepo
  4. 初始化仓库并设置所属用户为git,这里建了一个叫test的仓库。
  5. root@zabbix-server .ssh]# cd /home/git/gitrepo/
  6. [root@zabbix-server gitrepo]# git init --bare test.git
  7. Initialized empty Git repository in /home/git/gitrepo/test.git/
  8. [root@zabbix-server gitrepo]# chown -R git. /home/git/gitrepo/          ##因为这里的gitrepo路径下有多个文件,所以加-R参数递归
  9. 到此,git服务器就算搭建完成,URL地址如下:
  10. git@192.168.220.128:/home/git/gitrepo/test.git
  11. 测试1 --git clone
  12. 以下简单测试Clone和Push,如果你之前用过git,那么得到上边的仓库地址后应该就非常熟悉了。
  13. clone--zabbix-proxy客户端
  14. [root@zabbix-proxy ~]# mkdir -p $HOME/A
  15. [root@zabbix-proxy ~]# cd A/
  16. [root@zabbix-proxy A]# git clone git@192.168.220.128:/home/git/gitrepo/test.git   #这里并不需要输入上边创建git用户的密码,如果需要输入密码,说明公钥添加有误,请重新检查。
  17. Cloning into 'test'...
  18. warning: You appear to have cloned an empty repository.
  19. [root@zabbix-proxy A]# ls
  20. test
  21. [root@zabbix-proxy A]# cd test
  22. [root@zabbix-proxy test]# ls
  23. [root@zabbix-proxy test]# touch 1
  24. [root@zabbix-proxy test]# git add .
  25. [root@zabbix-proxy test]# git commit -m "ceshi"
  26. [master (root-commit) e3b8d5b] ceshi
  27.  1 file changed, 0 insertions(+), 0 deletions(-)
  28.  create mode 100644 1
  29. [root@zabbix-proxy test]# git push origin master      #通过克隆来的远程仓库,默认有个别名叫origin,所以推送可以直接这样:
  30. Counting objects: 3, done.
  31. Writing objects: 100% (3/3), 193 bytes | 0 bytes/s, done.
  32. Total 3 (delta 0), reused 0 (delta 0)
  33. To git@192.168.220.128:/home/git/gitrepo/test.git
  34.  * [new branch]      master -> master
  35. [root@zabbix-proxy test]# mkdir -p $HOME/B             #再次克隆
  36. [root@zabbix-proxy test]# cd $HOME/B
  37. [root@zabbix-proxy B]# git clone git@192.168.220.128:/home/git/gitrepo/test.git
  38. Cloning into 'test'...
  39. remote: Counting objects: 3, done.
  40. remote: Total 3 (delta 0), reused 0 (delta 0)
  41. Receiving objects: 100% (3/3), done.
  42. [root@zabbix-proxy B]# ls
  43. test
  44. [root@zabbix-proxy B]# cd test
  45. [root@zabbix-proxy test]# ls               #可以看到这个就是刚才提交文件
  46. 1
  47. 测试2 --git remote #需要有本地仓库
  48. [root@zabbix-proxy ~]# mkdir -p $HOME/C
  49. [root@zabbix-proxy ~]# cd $HOME/C
  50. [root@zabbix-proxy C]# git init #初始化创建本地仓库
  51. Initialized empty Git repository in /root/C/.git/
  52. [root@zabbix-proxy C]# git remote add origin git@192.168.220.128:/home/git/gitrepo/test.git #git远程添加源
  53. [root@zabbix-proxy C]# git push -u origin master #将本地的master分支推送到origin主机,同时指定origin为默认主机
  54. error: src refspec master does not match any.
  55. error: failed to push some refs to 'git@192.168.220.128:/home/git/gitrepo/test.git'
  56. [root@zabbix-proxy C]# git pull git@192.168.220.128:/home/git/gitrepo/test.git ##在上传你的代码之前因为产生冲突会报错,提交不上,通常要进行拉取代码。
  57. remote: Counting objects: 26, done.
  58. remote: Compressing objects: 100% (18/18), done.
  59. remote: Total 26 (delta 4), reused 0 (delta 0)
  60. Unpacking objects: 100% (26/26), done.
  61. From 192.168.220.128:/home/git/gitrepo/test
  62. * branch HEAD -> FETCH_HEAD
  63. [root@zabbix-proxy C]# ls
  64. 1 README runoob.php test.txt
  65. [root@zabbix-proxy C]# git branch
  66. * master
  67. [root@zabbix-proxy C]# echo 1111111 >ceshi
  68. [root@zabbix-proxy C]# git add .
  69. [root@zabbix-proxy C]# git commit -m "add ceshi"
  70. [master 6e0e239] add ceshi
  71. 1 file changed, 1 insertion(+)
  72. create mode 100644 ceshi
  73. [root@zabbix-proxy C]# git push -u origin master ##将本地的master分支推送到origin主机,同时指定origin为默认主机
  74. Counting objects: 4, done.
  75. Delta compression using up to 2 threads.
  76. Compressing objects: 100% (2/2), done.
  77. Writing objects: 100% (3/3), 257 bytes | 0 bytes/s, done.
  78. Total 3 (delta 1), reused 0 (delta 0)
  79. To git@192.168.220.128:/home/git/gitrepo/test.git
  80. 0e88423..6e0e239 master -> master
  81. Branch master set up to track remote branch master from origin.
  82. [root@zabbix-proxy C]#

git clone与git pull的区别 

点击下面链接:
git上传_提交代码前先git pull吗_年少不知富婆好的博客-CSDN博客

git如何拉取指定分支的代码

问题背景:

  新项目还在开发阶段,没有正式对外发布,所以开发同事合并代码到develop上(或者其他名称分支上),而不是到master分支上

  通过git拉取代码的时候,默认拉取的是master分支,如下图:

拉取指定分支代码解决方案:

以拉取develop分支的代码为例, 要拉取其余分支代码类似操作

1.使用git命令拉取

命令:git clone -b develop XXX 其中develop就是分支的名称

2.使用TortoiseGit工具拉取 

git fetch与git merge

参考内容:Git 远程仓库(Github) | 菜鸟教程

  • 执行 git fetch origin master 时,它的意思是从名为 origin 的远程上拉取名为 master 的分支到本地分支 origin/master 中。既然是拉取代码,当然需要同时指定远程名与分支名,所以分开写。
  • 执行 git merge origin/master 时,它的意思是合并名为 origin/master 的分支到当前所在分支。既然是分支的合并,当然就与远程名没有直接的关系,所以没有出现远程名。需要指定的是被合并的分支。
  • 执行 git push origin master 时,它的意思是推送本地的 master 分支到远程 origin,涉及到远程以及分支,当然也得分开写了。
  • 还可以一次性拉取多个分支的代码:git fetch origin master stable oldstable
  • 也还可以一次性合并多个分支的代码:git merge origin/master hotfix-2275 hotfix-2276 hotfix-2290
  1. 服务器A
  2. [root@dongm xuexi]# ls
  3. 11111 1.txt ceshi.c ceshi.ccccccc ceshi.sh test.c test.txt xinjian.txt
  4. [root@dongm xuexi]# echo 555555 >11111111111.txt
  5. [root@dongm xuexi]# git add .
  6. [root@dongm xuexi]# git commit -m "add 1111111111.txt"
  7. [master c3d767b] add 1111111111.txt
  8. 1 file changed, 1 insertion(+)
  9. create mode 100644 11111111111.txt
  10. [root@dongm xuexi]# git push origin master
  11. Counting objects: 4, done.
  12. Delta compression using up to 2 threads.
  13. Compressing objects: 100% (2/2), done.
  14. Writing objects: 100% (3/3), 260 bytes | 0 bytes/s, done.
  15. Total 3 (delta 1), reused 0 (delta 0)
  16. remote: Resolving deltas: 100% (1/1), completed with 1 local object.
  17. To git@github.com:dongmin6/test.git
  18. 3f7513d..c3d767b master -> master ##增加文件11111111111.txt
  19. [root@dongm xuexi]# ls
  20. 11111 11111111111.txt 1.txt ceshi.c ceshi.ccccccc ceshi.sh test.c test.txt xinjian.txt
  21. 服务器B
  22. [root@dongm test]# git fetch origin
  23. From github.com:dongmin6/test
  24. 3f7513d..c3d767b master -> origin/master ##与仓库新增文件11111111111.txt对应
  25. [root@dongm test]# ls
  26. 11111 1.txt ceshi.c ceshi.ccccccc ceshi.sh README.md test.c test.txt xinjian.txt
  27. [root@dongm test]# git merge origin/master
  28. Merge made by the 'recursive' strategy.
  29. 11111111111.txt | 1 +
  30. 1 file changed, 1 insertion(+)
  31. create mode 100644 11111111111.txt
  32. [root@dongm test]# ls
  33. 11111 11111111111.txt 1.txt ceshi.c ceshi.ccccccc ceshi.sh README.md test.c test.txt xinjian.txt

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/513992
推荐阅读
相关标签
  

闽ICP备14008679号