使用WordPress的Git工作流程 - 本地居住 [英] Git Workflow with WordPress - Localhost to Live

查看:98
本文介绍了使用WordPress的Git工作流程 - 本地居住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本但常见的WordPress工作流问题。



当前工作流



  1. FTP文件(和数据库转储)到服务器以显示客户端

  2. 在本地进行请求更改

  3. FTP文件(和数据库转储)再次启动服务器

  4. 更多本地编辑

  5. FTP(和数据库转储)再次启动

  6. 清洗并重复使用

这已经成为一种怪物般的痛苦。必须有更好的方法

怀疑的Git工作流程


  1. 本地副本将成为我的主人

  2. 将文件推到某处 中间到我的实时/测试服务器

我想我应该如何在概念上做到这一点,但我不知道它应该如何实际完成。我应该在中间使用Github私人回购?有没有一种方法可以让我的Live网站直接从我的本地主机repo中拉?



如果这看起来很基本,或者已经被打死了,没有找到一个基本的这是你的工作流程应该如何看的指导。



感谢!



Terry

解决方案

看起来您根本没有使用版本控制。你要开始是个好主意。我只是从SVN转换为Git,而我正在做一些更为宏大的工作。让我们从您的目标入手:


  1. 获取版本控制

  2. 通过Git建立某种Web部署

  3. 远程托管版本控制

人们会告诉你,Git不是Web部署工具 - 他们可能是对的,但到目前为止,它对我来说工作正常,我做了类似的事情。幸运的是,我在Wordpress安装练习 - 这是我采取的步骤。


  1. 使用Git安装并安装到所有客户端。

  2. 下载最新版本的WordPress,安装在一个vanilla中。 git init
  3. 将主分支到dev和live中

  4. 在本地工作,在dev中提交,然后

现在,我最终回过头去做的是创建一个 gitolite 服务器虚拟机并使用它作为我的主机 - 这有效地取代了你的例子中的github。我认为你知道一个远程仓库的价值 - 我肯定会追寻这条路线。



我会在推荐的第2步中回溯一秒钟。你应该保留主版本的WordPress版本,这样你就可以升级核心,看看它如何与你的自定义代码一起玩,而不是像你的某个分支之类的东西升级核心,一切都打破。这对我来说非常方便,而且我肯定会在Magento这样的大型项目中使用它。



好的,回到部署。你可以在你的web服务器上放一个git客户端,并在它的分支中放入 pull - 但你必须考虑一些特殊的计划。你的prod文件在某些​​地方很可能与你的dev文件不同,尤其是配置(数据库等) - 你要确保这些文件位于 .gitignore ,所以你不会在 prod 环境中拉动 dev configs。

我主要总结了当我开始研究这个项目时人们告诉我的内容,所以我希望它有帮助。再次,我略微超过了你的位置,所以如果有人有任何更正/优化,请随时发表评论。

I have a basic but common WordPress workflow question.

Current Workflow

  1. I develop everything locally
  2. FTP files (and database dump) up to the server to show client
  3. Make requested changes locally
  4. FTP files (and database dump) up the server again
  5. More local edits
  6. FTP (and database dump) up again
  7. Rinse and repeat

This has become a monster pain. There has to be a better way

Suspected Git workflow

  1. Local copy will be my ‘master’
  2. ‘Push’ files up to somewhere
  3. ‘Pull’ files from this place in the middle to my live/testing server

I think I have an idea of how it should conceptually be done, but I don’t know how it should practically be done. Should I use a Github private repo in the middle? Is there a way for my Live site to "Pull" directly from my localhost repo?

Apologies if this seems elementary or beaten to death already, but I’ve searched and haven’t found a basic "This is how your workflow should look" guide.

With thanks!

Terry

解决方案

It looks like you're not using version control at all. It's a good idea that you're going to start. I just converted from SVN to Git, and I'm sort of doing what you're doing at a grander level. Let's start with your objectives:

  1. Get version control
  2. Establish some sort of web deployment via Git
  3. Host the version control remotely

People will tell you that Git is not a web deployment tool - they may be right, but so far it is working ok for me, and I did something similar. Lucky for you, I practiced on a Wordpress install - here's the steps that I took.

  1. Got everything with Git setup and installed as far as client goes.
  2. Downloaded the latest version of Wordpress in a vanilla install.
  3. git init the base install with no modifications
  4. Branched the master into "dev" and "live"
  5. Work locally, committing in "dev", then once changes are done, merged to live.

Now, what I ended up going back and doing was creating a gitolite server VM and using that as my host - this effectively replaced github in your example. I think you know the value of a remote repository - I would definitely pursue that route.

I'm going to backtrack for a second on step 2 of my recommendations. You should keep the vanilla version of Wordpress on the master so you can upgrade the core and see how it plays with your custom code, instead of upgrading the core on something like one of your branches and everything breaking. This has been pretty convenient for me, and something that I'm going to definitely use on larger projects like Magento.

Ok, back to the deployment. You could put a git client on your webserver and have it pull from its branch in the workflow - but you have to take some special planning considerations. Your prod files will most likely be different than your dev files in certain places, particularly configuration (database, etc) - you're going to want to make sure that those files are in .gitignore so you're not pulling up dev configs into your prod environment.

I've mostly summed up what people told me when I started working on this so I hope it helps. Again, I'm just slightly past where you are, so if anyone has any corrections/optimizations, please feel free to comment.

这篇关于使用WordPress的Git工作流程 - 本地居住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆