Git Workflow with WordPress - Localhost to Live

前端 未结 3 912
再見小時候
再見小時候 2020-12-24 03:08

I have a basic but common WordPress workflow question.

Current Workflow

  1. I develop everything locally
  2. FTP files (and database
3条回答
  •  有刺的猬
    2020-12-24 03:30

    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.

提交回复
热议问题