ben(ny) pearson|

Notes on the “WordPress and Git” video series by Amelia Briscoe (Part 1)

These are my reference notes on the excellent video series WordPress and Git by Amelia Briscoe. Many thanks to Amelia for creating this series, sharing it and allowing me to post this summary. This post covers the first four videos. My second post (Part 2) will cover the last five videos.

Links

Contents

 

Video 1. Importing a WordPress Git Repository

Mark Jaquith’s WordPress Skeleton –  A basic layout of a WordPress Git repository

Features of WordPress Skeleton

Importing WordPress Skeleton into Bitbucket

 

Video 2. Clone a WordPress Git Repository to a local server

Forking the repository for local use

git clone --recursive https://benpearson@bitbucket.org/benpearson/development-repo.git wp_development

Explanation of the git clone command

Finish cloning repo and create a database

 

Video 3. Configure the WordPress Git Repository

Consider the following code from the top of the wp-config.php in the newly cloned local repo.

if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) {
    define( 'WP_LOCAL_DEV', true );
    include( dirname( __FILE__ ) . '/local-config.php' );
} else {
    define( 'WP_LOCAL_DEV', false );
    define( 'DB_NAME', '%%DB_NAME%%' );
    define( 'DB_USER', '%%DB_USER%%' );
    define( 'DB_PASSWORD', '%%DB_PASSWORD%%' );
    define( 'DB_HOST', '%%DB_HOST%%' ); // Probably 'localhost'
}

This code looks for the file local-config.php. If it exists, the database information contained in the file in local-config.php is used. If it does not exist, the database information listed below the conditional (above) is used. The file local-config.php will not exist in the repository because it is listed in the .gitignore file.

.gitignore also contains /content/upgrade/ so that any WordPress upgrades made in the local environment will not be pushed to the repo

Setting up the config files

define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/content' );

Should be changed to something like following (where wp_development is the name of my local folder)

define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp_development/content' );
define('WP_MEMORY_LIMIT', '96M');

 

Video 4. Installing WordPress from a Git Repository

You may get the following message if using Windows:

warning: LF will be replaced by CRLF in .htaccess
The file will have its orginal line endings in your working directory

In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). When you get code from git that was uploaded from a unix system they will only have a LF. It’s nothing to worry about. More information on this warning from stackoverflow