Starting a new WP project with WP-Skeleton

Install using Mark Jaquith’s method. This involves

  1. Handling differing database connection details
  2. Handling plugins that can’t or shouldn’t run on a localhost

Create a local subdirectory. Then clone Mark Jaquith’s wp-skeleton into a new directory www. Or, if you already did the steps below, clone it directly from your own fork.

Note: use recursive cloning otherwise the submodule will not be cloned:

git clone --recursive https://github.com/markjaquith/WordPress-Skeleton.git www

Create your own Git repo (named after your project). I created wptest2 at bitbucket.org
Remove the remote repo from your local repo:

git remote rm origin

And add the new remote repo:

git remote add origin ssh://git@bitbucket.org/sdims/wptest2.git
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags

The wp-config.php is in the root. Now open up your wp-config.php file  and change the names to the ones you will use on the server.
Some notes from Mark Jaquith:

  • For local development, create /shared/ (it is ignored by Git), and have the files live there. For production, have your deploy script (Capistrano is my choice) look for symlinks pointing to /shared/ and repoint them to some outside-the-repo location (like an NFS shared directory or something). This gives you separation between Git-managed code and uploaded files.
  • What’s the deal with local-config.php?
    A: It is for local development, which might have different MySQL credentials or do things like enable query saving or debug mode. This file is ignored by Git, so it doesn’t accidentally get checked in. If the file does not exist (which it shouldn’t, in production), then WordPress will used the DB credentials defined in wp-config.php.
  • (Use WP_LOCAL_DEV in other tasks that are different for the live server and the local installation (such as backups etc))

Server stuff

Follow the steps pointed out in a previous post. Summarized:

Go to the working directory of your website (the Prime):

$ cd ~/www
$ git init 
$ touch test.txt # extra step for empty dir: create a test.txt file (so there is something to commit)
$ git add . 
$ git commit -m"initial import of pre-existing web files"

create a bare repository outside the web directory, this is Hub.cd

$ cd; mkdir site_hub.git; cd site_hub.git 
$ git --bare init

from inside Prime’s working directory, add Hub as a remote and push Prime’s master branch:

$ cd ~/www 
$ git remote add hub ~/site_hub.git 
$ git remote show hub
$ git push hub master

create post-update in the Hub repository (in hooks/):

#!/bin/sh 
echo 
echo "**** Pulling changes into Prime [Hub's post-update hook]" 
echo 

cd $HOME/www || exit 
unset GIT_DIR git 
pull hub master 

exec git-update-server-info

create post-commit in the Prime repository (in .git/hooks/):

#!/bin/sh 

echo 
echo "**** pushing changes to Hub [Prime's post-commit hook]" 
echo 

git push hub

Give the right permissions to both the hooks:

chmod +x <hook>

Deny acces to git repositories. important!
Add the following to your top-level .htaccess file to forbid web access:

# deny access to the top-level git repository: 
RewriteEngine On 
RewriteRule \.git - [F,L]

Back to local

To keep things simple for now I avoid using submodules in the repo

SO remove the submodule for wp
To remove a submodule you need to:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule
  6. Commit
  7. Delete the now untracked submodule files
    rm -rf path_to_submodulegit

Now simply clone wordpress into a directory  outside of the repo

git clone 
https://github.com/WordPress/WordPress.git

Create a new wp dir in the repo root
Copy everything except .* files to this dir (just skipping .git is not enough)

cp -r WordPress/!(.*) destination_dir

Commit the changes

Now add the bare repository as a remote to your local repo

git remote add hub webmaster@debaskist.nl@ftp.greenhost.nl:repos/site_hub.git

merge remote, you may also delete the test.txt, and push back:

$ git fetch hub
 $ git merge hub/master
 $ rm test.txt
 $ git commit -am 'removed test.txt'
 $ git push hub

 Configure WAMP

If the local website is in a directory outside wamp/www, you will have to define an alias:

Go to wamp/alias/ , create a new file your_local_url.conf and put this in:

Alias /your_local_url "d:/path_to_www/"

<Directory "d:path_to_www/"> 
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

Restart WAMP services