Create a new repository on GitHub. Give it a reasonable long name (the clearer the better) and make sure that it’s private.
Go to Admin for the repository and add staff to the repo by going into “Collaborators” and typing the usernames.
Clone the new repository into the MAMP web root, either through GitHub for Mac or on the command-line. For consistency, clone it to a folder that has the same name as the repository.
git clone [email protected]:imaginepublishing/how-it-works.git
If the repo is using any shared libraries (either public or private) then these should be configure these as submodules. See “Using Submodules“.
Add any files that have already been created for the repo or files that are not under version control elsewhere (e.g. unzipping a fresh WordPress install into the folder). Setup a .gitignore file (see “GitIgnore General Considerations” as well as any platform-specific considerations).
Add all the files to a commit, give it the message “Initial commit” and sync with GitHub, either through the Mac client or on the command-line:
git add . git commit -m "Initial commit" git push origin master
Local Web Server Setup
Your local repo should have been cloned into the “document root” folder of MAMP (“/Applications/MAMP/htdocs”). To get the files served via the local server, we need configure a virtual host within MAMP.
Open “/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf”. Duplicate a virtual host block and configure it like so:
<VirtualHost *:8888> ServerName how-it-works.local DocumentRoot "/Applications/MAMP/htdocs/how-it-works/" </VirtualHost>
The prefix for the ServerName should match the name of the GitHub repo. The DocumentRoot should point to the folder that was cloned, which will also have the same name as the GitHub repo. Note the default MAMP port number of 8888. Restart MAMP for it to take effect.
Important: MAMP does not include the virtual hosts configuration by default. If it is a fresh MAMP install, then open “/Applications/MAMP/conf/apache/httpd.conf” and uncomment the line that includes this file (around line #525).
For each new virtual host that is set up in this manner, you’ll need to add a line to the systems hosts file. This will tell your browsers and any other network applications that, for example, “how-it-works.local” is served by your machine and not the wider network.
A simple line like this, added to the file “/etc/hosts”:
You will need a database snapshot for any sites that you are working with offline. These can be obtained by doing an export from the phpMyAdmin install at http://www.imagine-publishing.co.uk/mysqladm/. Logins and passwords for each site are in the passwords master file.
The data can then be imported into your local database provided by MAMP. There is a similar phpMyAdmin interface for this, accessible from the MAMP start page. Again, for consistency create a database with the same name as the repo, and then upload and import the file generated by the export.
Important: WordPress stores path-specific information in the database – an annoying practice that means that after importing into a test system, some find and replace actions need to be carried out. See “Moving WordPress Databases.”
Some files will not be present when you clone from the GitHub repo for safety reasons. These include things like wp-config.php and .htaccess files. These will always differ between live and test versions, so they are added to the .gitignore file in order to not overwrite them when pushing changes up to live servers.