WordPress & Version Control: A Workflow
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

WordPress & Version Control: A Workflow

on

  • 5,536 views

I’ve spent quite a bit of time refining and perfecting my development workflow. I’d like to share how I use WordPress with version control to still develop locally and easily push changes live ...

I’ve spent quite a bit of time refining and perfecting my development workflow. I’d like to share how I use WordPress with version control to still develop locally and easily push changes live with the push of a button. No more dragging files into FTP! No more losing changes because of stupid accidents!

Statistics

Views

Total Views
5,536
Views on SlideShare
5,403
Embed Views
133

Actions

Likes
10
Downloads
41
Comments
1

4 Embeds 133

http://a7web.com 101
https://twitter.com 23
http://aaronjholbrook.com 6
http://twitter.com 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

WordPress & Version Control: A Workflow Presentation Transcript

  • 1. WordPress  and   Version  Control A Workflow $ Aaron Holbrook A7 Web Design, Owner aaron@a7web.comMonday, June 11, 12
  • 2. aaron@a7web.com @aaronjholbrook a7web.com #wcmke #wpgitMonday, June 11, 12
  • 3. overview Background Disclaimer Assumptions Local Development Version Control (Git) Using WordPress & Git together Deployment Some demos Ask questions! #wcmke #wpgitMonday, June 11, 12
  • 4. have you ever... Wanted to make your changes live with the push of a button? Hated dragging files into FTP and wished for a better way? Been editing via FTP, made a change, closed the editor and immediately realized you shouldn’t have closed it? Lost code and didn’t have a backup? Had a backup, but it was too old? Had a site become corrupt, infected or lost with no way to recover it? #wcmke #wpgitMonday, June 11, 12
  • 5. a little history I had 10+ WordPress sites to maintain Sites were similar in layout and style differing only by color scheme Needed a way to quickly push out changes across all the sites Really wanted to utilize version control #wcmke #wpgitMonday, June 11, 12
  • 6. disclaimer! ma y vary) ileage YMMV (your m This workflow is something that I’ve refined to suit my needs, feel free to adjust it to suit yours #wcmke #wpgitMonday, June 11, 12
  • 7. assumptions You’re aware of how important Version Control is, but have not fully integrated it into your workflow You have some familiarity with the command line Your live server environment supports SSH (most hosts support SSH, sometimes you have to ask) You have a local development environment that you prefer to work within You’d like to have seamless, simple deployments #wcmke #wpgitMonday, June 11, 12
  • 8. the workflow Start local, develop some functionality Set up deployment system to your live server Deploy your changes with the press of a button! #wcmke #wpgitMonday, June 11, 12
  • 9. things you’ll need Terminal Git SSH #wcmke #wpgitMonday, June 11, 12
  • 10. legend Whenever you see $ command here Everything after the $ is what you should type #wcmke #wpgitMonday, June 11, 12
  • 11. “A civilized tool for a civilized age” - Si, stack overflowMonday, June 11, 12
  • 12. git 101 You can define a Git repository in any directory simply by typing: $ git init Via the terminal, navigate to the root of your local site directory and type $ git init #wcmke #wpgitMonday, June 11, 12
  • 13. .gitignore .DS_Store wp-config.local.php .htaccess Optional - ignore user uploads wp-content/uploads/ Optional - ignore live cache wp-content/cache/ #wcmke #wpgitMonday, June 11, 12
  • 14. git 102 In your git repo, add all files $ git add . Commit! $ git commit -m “Commit Message” Success! -m allows an i nline commit m essage #wcmke #wpgitMonday, June 11, 12
  • 15. DeployMonday, June 11, 12
  • 16. this file is t wp-config.local.php he m agic key 1. Define local variables without contaminating the server 2. Add a call to wp-config.php to check for this file and load it if it exists Credit to Mark Jaquith who came up with this idea #wcmke #wpgit http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/Monday, June 11, 12
  • 17. this file is t wp-config.local.php he m agic key #wcmke #wpgitMonday, June 11, 12
  • 18. wp-config.php 1. Test for wp-config.local.php 2. If it doesn’t exist, then use live server connection information #wcmke #wpgitMonday, June 11, 12
  • 19. wp-config.php #wcmke #wpgitMonday, June 11, 12
  • 20. ssh 101 1. $ ssh login@server.com 2. Enter password 3. success #wcmke #wpgitMonday, June 11, 12
  • 21. HUB & PRIME On the server, we will create two repositories HUB will be the main collaborator PRIME will be the live site repository Major props to Joe Maller #wcmke #wpgit http://joemaller.com/990/a-web-focused-git-workflow/Monday, June 11, 12
  • 22. hub HUB Create hub as a bare repository I generally put it right above the site’s html root in a ‘git-hub’* folder /domains/site.com/html /domains/site.com/git-hub $ git init --bare * Not to be confused with the fantastic GitHub website #wcmke #wpgit https://github.com/Monday, June 11, 12
  • 23. HUB hook We’ll want PRIME to auto-update when we push our changes up to H HUB So let’s set up a hook! #wcmke #wpgitMonday, June 11, 12
  • 24. HUB hook /git-hub/hooks/post-update #wcmke #wpgitMonday, June 11, 12
  • 25. PRIME 1. Create as regular repo $ git init 2. Add remote to HUB $ git remote add hub /domains/site.com/git-hub #wcmke #wpgitMonday, June 11, 12
  • 26. and finally Set up our local remote to HUB $ git remote add hub ssh://login@host.com/home/domains/site.com/git-hub Success! #wcmke #wpgitMonday, June 11, 12
  • 27. 3...2...1... blast off! Make sure that our repository is clean $ git add . $ git commit -am “Updated header to include nav links” ...wait for it... $ git push hub master We’ve deployed! hooray! #wcmke #wpgitMonday, June 11, 12
  • 28. push & pull Occasionally you will need to commit on the server and pull down to your local repository All you need to do (from local machine) $ git pull hub master #wcmke #wpgitMonday, June 11, 12
  • 29. caution! The uploads folder can change quite frequently, which may cause your repos to get out of sync, necessitating a need for frequent pulldowns to keep repos in check Depending on situation, you can ignore uploads/* directory or sync repos /uploads/* frequently #wcmke #wpgitMonday, June 11, 12
  • 30. take away Start local, develop some functionality Set up deployment system to your live server Deploy your changes with the press of a button! #wcmke #wpgitMonday, June 11, 12
  • 31. a7web.com @aaronjholbrook aaron@a7web.com #wcmke #wpgitMonday, June 11, 12