zoukankan      html  css  js  c++  java
  • git 远程版本库,github提供服务原理,git自动更新发送邮件

    1.安装好Linux,安装好Git(192.168.1.239)

    2.创建一个用户zph(让此用户提供Git on server),密码设置为12345678

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. # useradd zph  

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. # passwd zph  
    3.切换到zph用户

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. # su zph  
    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ cd  

    4.创建一个远程仓库

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ git init --bare sample.git  

    5.在windows下(192.168.1.5),打开git bash

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ git clone zph@192.168.1.239:/home/zph/sample.git  
    终端会让输入密码,此时输入zph用户的密码即(12345678)

    6.为了让用户,不用每次都输入密码,在linux生成.ssh目录

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ ssh-keygen -t rsa -C "youremail@example.com"  
    7.进入.ssh,新建一个authorized_keys文件

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ cd /home/zph/.ssh/  
    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ vi authorized_keys  
    8.打开windows中当前用户的.ssh/id_rsa.pub,复制里面的内容,粘贴到第7步中的authorized_keys中

    9.更改authorized_keys文件的权限

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $chmod 600 authorized_keys  
    10.验证authorized_keys有没有生效,打开windows

    [python] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. $ ssh zph@192.168.1.239  
    如果不需要输入密码,代表生效了

    11.重复第5步,已经不需要输入密码了

    12.代码自动更新

    cp /home/zph/sample.git/hooks/post-update.sample /home/zph/sample.git/hooks/post-update

    13.打开post-update,先清空内容,然后进行编辑如下

    #!/bin/bash

    #如果想要发送邮件则开启下面两行,关于发送邮件请访问 http://blog.csdn.NET/zph1234/article/details/50509885

    #var=`git show`
    #PHP /var/www/html/mail.PHP "$var"

    cd /usr/share/nginx/html/sample
    unset GIT_DIR

    git checkout master
    git pull

    14.出于安全考虑,只让克隆提交版本库,不让登陆终端

    $ which git-shell
    /usr/bin/git-shell
    vi /etc/passwd

    ph:x:1000:1000:zhangpenghui:/home/zph:/usr/bin/git-shell

  • 相关阅读:
    Mac上安装Git
    原型对象和原型链
    ES6入门
    一边宽度固定,一边宽度自适应
    15种css居中方式
    阿里CDN核心技术解密
    尽量用const,enum,inline代替define
    Nginx安装
    百度笔试题:malloc/free与new/delete的区别(转)
    C++内存管理(转)
  • 原文地址:https://www.cnblogs.com/hehe520/p/6147489.html
Copyright © 2011-2022 走看看