Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to git & WordPress

729 views

Published on

A brief introduction on git and some tips for using it with WordPress

Published in: Internet, Technology, Business
  • Be the first to comment

  • Be the first to like this

Introduction to git & WordPress

  1. 1. git and WordPress
  2. 2. Who am I? ● Owner & Director @ QC Creative ● PHP/MySQL Developer since 2004 ● Front-end Specialist since 2007 ● Amateur Photographer ● Lifelong Learner...
  3. 3. Why should you listen to me? ● Built custom PHP applications for clients like Magic Hat & UVM ● Since 2010, have used WordPress for >90% of projects ● Host & manage over 60 WordPress sites
  4. 4. How do we deploy now? ● “Cowboy Coding” ● FTP/SFTP/SCP with a local development environment or staging server ● FTP/SFTP/SCP with local development AND a staging server
  5. 5. Have you ever wondered... ● Did I edit that CSS file on my local copy or on the FTP server? ● If I upload this, will it break anything? ● What if my client/boss wants me to undo all of these changes?
  6. 6. We should be able to answer... ● Who changed this file? ● What did this file look like before? ● Where has this file been uploaded? ● When was this file changed? ● Why was this file changed?
  7. 7. Version Control to the Rescue! Version control: ● tracks changes to files, as well as variations or “branches” of an entire project ● allows us to move through a history of snapshots of our project ● allows us to share our work with others seamlessly
  8. 8. Some words... Repository Branch Commit Clone Remote Check out Push Pull Fetch
  9. 9. git vs. SVN In theory: ● SVN is centralized. ● git is decentralized. In practice: ● git is often used with a centralized repository.
  10. 10. SVN is centralized ● Complete project history is stored on a central server. ● Individual developers “check out” the latest versions of files in order to work on them. ● Branches are complete copies of the project, stored in a separate folder.
  11. 11. git is distributed ● Every git repository contains a complete history of the entire project. ● Any git repository can act as a “remote” for any other git repository. ● Branches are cheap — they are just pointers.
  12. 12. In practice, git is centralized too... ● git doesn’t care, but for the humans, it is usually best to declare a canonical central repository. ● Usually you’ll use a hosted service like github or bitbucket for this, but it is also possible to host yourself. ● Teams may still share work amongst themselves before “pushing” to the central repository.
  13. 13. Using git with subteams and a central repository
  14. 14. WordPress core development ● WordPress core development still uses SVN :( ● It is possible to use git for core development, and convert your patches to SVN :)
  15. 15. git basics ● Working directory ● Staging area ● HEAD
  16. 16. The git workflow
  17. 17. Using Branches Best ● With git, branches are your friends. ● Branch early, branch often. ● Learn how interactively:http://pcottle.github.io/learnGitBranching/
  18. 18. For sole developers ● Designate a branch as your “clean” branch — usually `master`. ● Create a new branch for each new feature or story. ● As a feature is completed and tested, merge its branch into your clean branch, then deploy. ● Optionally maintain designated branches for each server, to track what has been deployed. ● ONLY merge changes into server branches after you have deployed the changes.
  19. 19. For teams Read about git-flow or github-flow.
  20. 20. Remote repositories ● Remote repositories can be anywhere. ● Usually, access is via SSH with private keys for passwordless interactions. ● Sometimes the live site is a git repository.
  21. 21. We don’t want to track everything ● .gitignore is a plaintext file that tells git which files and folders to ignore ● Create one for every repository ● Essential for using git with WordPress ● What to ignore: o wp-content/uploads o local config files o self-contained external libraries
  22. 22. Using git with WordPress ● What do I track in git? o My custom theme? o My entire wp-content folder? o My entire public folder? o My entire project folder? ● Where do I keep my repositories?
  23. 23. My philosophy Track everything. Keep it anywhere.
  24. 24. 2011: Mark Jaquith’s WP Skeleton ● Mark Jaquith is one of the lead WP Core developers. ● Mark really doesn’t want you to cowboy code. ● He made WP-Skeleton, which is a starter git repository for WordPress project.
  25. 25. WP Skeleton ● WordPress core files are kept in a subdirectory, tracked as a git submodule. ● wp-config.php is modified to allow local configuration overrides. ● Everything is awesome… ● Right?
  26. 26. Not quite... ● git submodules are a major PITA. ● Submodules are not designed for dependency management. ● Local config options could be more robust and allow for multiple environments.
  27. 27. We need Dependency Management ● Wouldn’t it be great if we could keep one list of all of the external plugins, themes, and libraries required by our site, and have it always kept up to date? ● Composer can do that for you.
  28. 28. Composer ● Installs, tracks and manages PHP libraries. ● WordPress is a PHP library ● WordPress plugins are PHP libraries ● WordPress themes are PHP libraries ● Most WordPress-directory plugins are available for Composer through wpackagist.org
  29. 29. Roots.io & Bedrock ● Bedrock is an open source WordPress “starter pack.” ● It has everything you need to start using composer and git with your WordPress projects. ● Available at: https://github.com/roots/bedrock
  30. 30. Thanks! Thank you to Gregg Bense for organizing this event Thank you to the Fletcher Free Library for hosting this event
  31. 31. Questions? Josh Lee (802) 735.2274 josh@qccreative.com
  32. 32. Additional Resources BitBucket (http://bitbucket.org) Github (http://github.org) Source Tree (http://www.sourcetreeapp.com/) Tower (http://www.git-tower.com/) git-scm book (http://git-scm.com) https://help.github.com/articles/generating-ssh-keys (The best info on SSH keys and how to use them with git) http://rkulla.blogspot.com/2011/08/some-points-on-git-vs-subversion.html http://www.slideshare.net/terrywang/git-101-tutorial-presentation (700-slide presentation — very clear)http://pcottle.github.io/learnGitBranching/ (Interactive tutorial) http://danielkummer.github.io/git-flow-cheatsheet/ http://nvie.com/posts/a-successful-git-branching-model/ http://documentup.com/skwp/git-workflows-book http://wpengine.com/git/

×