[Solved] Learn to use GIT with WordPress and a hosting [closed]


One way I have made this work, is using two tools:

1) git deployment tutorial here

2) WP Command line http://wp-cli.org/

If you can install stuff on the host and ssh in, then you can set up a git repository on the server, set it up as a remote (e.g. called “deployment”), and push to it from your dev environment. Install a simple post-receive hook, which checks out your code into the website.

The master branch is checked out on the website, with the local remote set as the origin. When you push the master branch to the web server, you will need to log in with the ssh credentials (or set up a key). Once git receives this update, it runs the post-receive hook, which can simply cd to the working directory, and do a pull -q. This pulls from the master branch which has just been pushed from your dev. It all happens extremely quickly and reliably when it’s all set up.

I’d recommend installing WP normally, then allowing it to manage its own updates internally. Don’t try to do WP via git it gets pretty complicated.

Your code is probably a plugin, so the repository mentioned above would checkout to your plugin folder (the working directory).

Be careful to not modify any of the files on the server (in your working directory) else you may get conflicts and failures to deploy. But it sounds like you want to stop being a cowboy 🙂 Of course you need to ensure the plugin doesn’t write to files itself, e.g. temp files, caches etc. or at least craft git ignores to deal with them.

Then finally if you need to trigger anything in WP after your deploy your code, you can add wp-cli commands to the git post-receive hook.

Sorry if these aren’t beginner-level topics! But it gives you a starting point.

solved Learn to use GIT with WordPress and a hosting [closed]