• git同步开发更新至项目目录(转载)


    From:http://toroid.org/ams/git-website-howto

    本地版本库中存放开发的项目代码。以下内容介绍如何将本地版本库修改通过执行“git push web”命令同步到web站点目录。

    1、首先创建本地版本库:

    $ mkdir website && cd website
    $ git init
    Initialized empty Git repository in /home/ams/website/.git/
    $ echo 'Hello, world!' > index.html
    $ git add index.html
    $ git commit -q -m "The humble beginnings of my web site."

    本地版本库中包含需要同步到web网站的相关代码。

    2、远程版本库

    假设web站点建立在远程服务器上。在远程服务器上,创建一个镜像版本库:

    $ mkdir website.git && cd website.git
    $ git init --bare
    Initialized empty Git repository in /home/ams/website.git/

    然后,定义一个post-receive钩子文件,利用post-receive,检测最新更新,并同步最新更新到web根目录。post-receive文件内容如下:

    $ mkdir /var/www/www.example.org
    $ cat > hooks/post-receive
    #!/bin/sh
    GIT_WORK_TREE=/var/www/www.example.org git checkout -f
    $ chmod +x hooks/post-receive
    /var/www/www.example.org:此目录为web站点根目录


    3、本地版本库

    为本地版本库添加远程版本库路径,并指定push分支:

    $ git remote add web ssh://server.example.org/home/ams/website.git
    $ git push web +master:refs/heads/master

    4、查看远程服务器web根目录,可以看到新建的index.html文件。

    5、更新操作

    在本地版本库,执行以下命令,既可更新远程服务器的web根目录:

    git push web
  • 相关阅读:
    0509操作系统
    0508数据结构
    计算机组成原理
    0510数据库--基础知识
    0508操作系统
    0507数据结构
    0506操作系统和数据结构
    机试题201702x--不定长数组的输入
    机试题201805--输入n个字符串,将其反转输出
    SSH框架--Hibernate配置
  • 原文地址:https://www.cnblogs.com/xiaoerlang/p/4206544.html
Copyright © 2020-2023  润新知