zoukankan      html  css  js  c++  java
  • Linux下GIT服务器端和客户端搭建

    一、Git服务器端搭建

    备注:

    服务器ip:192.168.1.136

    客户端ip:192.168.1.135

    1.yum安装git服务器

    [root@server ~]# yum -y install git

    2.查看git版本

    [root@server ~]# git version

    git version 1.7.1

    3.创建客户端登录证书

    a:在客户端生成id_rsa.pub文件

    [root@client ~]#  ssh-keygen -t rsa

    b:将客户端生成的公钥传输到服务器端

    [root@client ~]#  scp id_rsa.pub root@192.168.52.136:/root/.ssh/authorized_keys

    c:在客户端用ssh连接服务器端测试来凝结是否成功

    [root@client ~]#  ssh 192.168.52.136

    [root@server~]#  ifconfig ech0

    4.服务器端初始化git仓库

    a:创建一个目录作为git仓库(Live_live.git)

    [root@server~]#  mkdir -p /data/Live_live.git

    b:初始化git仓库

    [root@server ~]# cd /data/Live_live.git/

    [root@server Live_live.git]# git init --bare

    Initialized empty Git repository in /data/Live_live.git/

    [root@server Live_live.git]# ls

    branches  config  description  HEAD  hooks  info  objects  refs

    [root@server Live_live.git]#

    5.测试

    在服务器端的/data/Live_live.git下创建一个代码存放目录

    [root@server Live_live.git]#  cd /data/Live_live.git/

    [root@server Live_live.git]#  git clone LIVE_code

    添加允许访问的用户

    [root@server ~]#  cd /data/Live_live.git/LIVE_code/

    [root@server LIVE_code/]#  git config --global  user.name "root"

    添加测试文件并提交

    [root@server LIVE_code/]#  echo "aaaa">test.txt

    [root@server LIVE_code/]#  git add .

    [root@server LIVE_code/]#  git commit -m "ceshi1"

    更新远程引用和相关的对象(提交代码)

    [root@server LIVE_code/]#  git push origin master

    二、Git客户端搭建

    1.yum安装git服务器

    [root@client ~]# yum -y install git

    2.查看git版本

    [root@client~]# git version

    git version 1.7.1

    3.下面我们克隆一个git仓库(Live_live.git)到客户端目录中

    [root@client~]# git clone root@192.168.52.136:/data/Live_live.git/LIVE_code /data/www/app.live.jjshowtime.com/

    Initialized empty Git repository in /data/www/app.live.jjshowtime.com/.git/

    reverse mapping checking getaddrinfo for bogon [192.168.52.136] failed - POSSIBLE BREAK-IN ATTEMPT!

    remote: Counting objects: 3, done.

    remote: Total 3 (delta 0), reused 0 (delta 0)

    Receiving objects: 100% (3/3), 223 bytes, done.

    4.我们可以在客户端查看下刚才提交的代码是否已经传输到app.live.jjshowtime.com目录下

    [root@client~]#  cd /data/www/app.live.jjshowtime.com

    [root@client app.live.jjshowtime.com]# ls

    test.txt

    [root@client app.live.jjshowtime.com]#

    5.查看一下当前test.txt文档内容

    [root@clientapp.live.jjshowtime.com]# cat test.txt

    aaaa

    [root@clientapp.live.jjshowtime.com]# 

    三、git pull测试

    1.在服务器端存放代码的目录下修改test.txt文件并提交文件

    [root@server LIVE_code/]# echo "bbbb">>test.txt

    [root@server LIVE_code/]# git add test.txt

    [root@server LIVE_code/]# git commit -m "ceshi2"

    [master 58ad8f3] ceshi2

     1 files changed, 1 insertions(+), 0 deletions(-)

    [root@server LIVE_code/]# git push origin master

    Everything up-to-date

    [root@server LIVE_code/]#

    2.在客户端执行git pull获取更新

    [root@client~]#  cd /data/www/app.live.jjshowtime.com

    [root@client app.live.jjshowtime.com]# git pull

    reverse mapping checking getaddrinfo for bogon [192.168.52.136] failed - POSSIBLE BREAK-IN ATTEMPT!

    remote: Counting objects: 5, done.

    remote: Total 3 (delta 0), reused 0 (delta 0)

    Unpacking objects: 100% (3/3), done.

    From 192.168.52.136:/data/Live_live.git/LIVE_code

       37b7bce..58ad8f3  master     -> origin/master

    Updating 37b7bce..58ad8f3

    Fast-forward

     test.txt |    1 +

     1 files changed, 1 insertions(+), 0 deletions(-)

    查看文件内容

    [root@client app.live.jjshowtime.com]# cat test.txt

    aaaa

    bbbb

    [root@client app.live.jjshowtime.com]#

    获取成功

     

     

    博主github地址:https://github.com/bazingafraser/cv 本文章为Bazingafraser作者原创,转载请注明出处,违权必究:http://www.cnblogs.com/bazingafraser/
  • 相关阅读:
    SSH框架中使用注解和xml配置的区别
    web项目中log4j的配置
    嵌入式—ASCII码
    MATLAB
    MATLAB
    MATLAB
    MATLAB
    CentOS 7将网卡名称eno16777736改为eth0
    图像增强处理
    Debussy与modelsim联仿时 do 文件脚本
  • 原文地址:https://www.cnblogs.com/bazingafraser/p/8483771.html
Copyright © 2011-2022 走看看