Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress & Version Control (v2) - WordCamp Chicago 2012

WordPress & Version Control (v2) - WordCamp Chicago 2012

Version Control lets you track your files over time. Why should you care? So when you mess up you can easily get back to a previous working version! I will take you through what version control is, why it’s important and how to start using it today on projects you’re already working on.

Aaron Holbrook

August 25, 2012
Tweet

More Decks by Aaron Holbrook

Other Decks in Technology

Transcript

  1. Full-time Freelance Web Developer (1.5yr) Web Developer & WordPress fanatic

    since 2005 Father, husband, gamer, geek AARON HOLBROOK
  2. CURRENTLY Founded and run A7 Web Design (3yrs) Global client

    base Theme & Plugin Author Core contributor Automation Script Builder Founded McHenry County WordPress Meetup
  3. OVERVIEW WTF is version control? Why should I care? Use

    it TODAY! WP & Version Control: A match made in heaven
  4. Incremental backups Short & long term undo Easier collaboration Track

    changes & ownership Sandboxing BE A BETTER DEV
  5. Create a Git repository in ANY directory $ git init

    Even existing projects!! INITIALIZE
  6. Create a branch (sandbox!) $ git branch NewBranch $ git

    checkout NewBranch $ git checkout master BRANCHING ...do some experiments, decide that we want to go back to where its safe:
  7. MERGING BRANCHES Commit changes on a branch $ git commit

    -m “NewBranch commit” $ git checkout master $ git merge NewBranch Check out the branch you wish to merge into Merge the branches!
  8. Special file: .gitignore Goes in the root of your repo

    Add filenames or directories that Git should ignore .GITIGNORE
  9. WP-CONFIG.LOCAL.PHP Define dev DB info Keeps dev DB separate from

    production DB this file is the magic key Credit to Mark Jaquith (@markjaquith) http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/
  10. Test for If it exists, use it If not, use

    Production DB info WP-CONFIG.PHP wp-config.local.php
  11. PASSWORDLESS SSH a@A:$ ssh-keygen -t rsa a@A:$ ssh b@B mkdir

    -p .ssh a@A:$ cat .ssh/id_rsa.pub | ssh b@B ‘cat >> .ssh/authorized_keys’
  12. Create two repositories on Production: -> collaboration (central hub) repo

    -> live site repo HUB PRIME Thanks to Joe Maller http://joemaller.com/990/a-web-focused-git-workflow/ HUB & PRIME
  13. $ git init --bare /domains/site.com/html /domains/site.com/git-hub Place outside of root

    in a ‘git-hub’* folder *Not to be confused with the fantastic GitHub https://github.com/ HUB
  14. HOOK IT UP Hooks allow you to run bash scripts

    upon certain criteria (a lot like WordPress!) We’ll want to create a hook so HUB updates PRIME automatically
  15. /domains/site.com/html PRIME $ git init $ git remote add hub

    /domains/site.com/git-hub Secure the .git directory with .htaccess!
  16. DEPLOY! $ git add . $ git commit -am “Updated

    header to include nav links” $ git push hub master
  17. PUSH / PULL $ git pull hub master If you

    make any changes directly on PRIME you will need to commit on PRIME and PULL to PRODUCTION
  18. CAUTION! If you did NOT put the wp-content/uploads folder in

    .gitignore, you will have to manually commit changes frequently
  19. PRETTY MUCH THIS Version control is amazing! It will improve

    your life! Using the basics is simple! Google is your friend!