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.
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.
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