zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Asp.net 基础4(自定义控件的使用之客户端脚本生成)
    Asp.net 基础3(自定义控件的使用)
    wpf 可以取消的单选checkbox
    wpf MaskedTextBox
    自定义 日期格式的datePicker
    wpf datagrid no record found style
    Sql语句绝妙用法
    .net反射简介
    c# 正则表达式小结
    如何获取地址栏地址
  • 原文地址:https://www.cnblogs.com/xiaoerlang/p/4206544.html
Copyright © 2011-2022 走看看