Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pxdsgnco/f9cdfb14068c68a79021e9735615c975 to your computer and use it in GitHub Desktop.
Save pxdsgnco/f9cdfb14068c68a79021e9735615c975 to your computer and use it in GitHub Desktop.
Deploy wordpress theme via git

Deploying WordPress Theme via Git

I needed to deploy a child theme to a server for folks to check out the development. I went with a git remote to get the good stuff from git to quickly recover if (when) I break something.

Server Setup

On the server, I created a new directory:

$ sudo mkdir -p /var/repos/theme_name.git
$ cd /var/repos/theme_name.git
$ sudo git --bare init

Then created a post-receive hook (`/var/repos/theme_name.git/hooks/post-receive):

#!/bin/sh
GIT_WORK_TREE=/var/www/wordpress.clir.org/wp-content/themes/theme_name git checkout -f

Don't forget to make it executable:

$ sudo chmod +x /var/repos/theme_name.git/hooks/post-receive

Probably good to change the permissions on it too:

$ sudo chown -R `whoami` /var/repos/theme_name.git/

I'm already in the group that can write to /var/www/wordpress/wp-content/themes/theme_name, but you may also need to check those permissions.

Deployment

On your local machine, you'll need to set up a new remote.

$ cd path/to/project
$ git remote add myserver ssh://username@server/var/repos/theme_name.git
$ git push myserver +master:refs/heads/master

After this initial setup, you can push "normally:"

$ git push myserver

winning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment