服务器上使用 git 更新 wordpress 内核方案

目录结构、场景设想

推荐目录架构结构:

/opts/mysite/
—/wordpress/
—/wp-config.php
—/index.php

*wordpress 要加入到 .gitignore 中,/mysite/index.php 需要修改加载 wordpress 的路径

场景 I 如果网站目录 mysite 是一个 repo(比如有 mysite/.git 目录)
场景 II 网站目录不是 repo ,而是部署为 detached worktree,即不存在 mysite/.git

方案 I(适用场景 I)

把 wordpress 当成 git submodule 加入到 repo 中。
http://blog.g-design.net/post/60019471157/managing-and-deploying-wordpress-with-git

方案 II(适用场景 II)

此时可以把 wordpress 子目录设置成 git repo(即存在 mysite/wordpress/.git 目录)
git clone git://github.com/wordpress/wordpress.git /opts/mysite/wordpress

*注意在 apache 中屏蔽 .git 目录

然后通过以下命令升级 wordpress 内核即可

git fetch --tags
sudo git checkout tags/4.1.1 -f

方案 III(适用场景 I 和 场景 II)

wordpress 子目录也配置成 detached worktree

直接下载最新 wordpress
git clone git://github.com/wordpress/wordpress.git /tmp/wordpress

使用 git checkout 命令更新

git fetch --tags
sudo git —git-dir=/tmp/wordpress/.git —work-tree=/opts/mysite/wordpress checkout tags/4.1.1 -f
    原文作者:肖建锋
    原文地址: https://segmentfault.com/a/1190000002578026
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞