2. Who am I?
● Owner & Director @ QC Creative
● PHP/MySQL Developer since 2004
● Front-end Specialist since 2007
● Amateur Photographer
● Lifelong Learner...
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. 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. 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. 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. 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
9. git vs. SVN
In theory:
● SVN is centralized.
● git is decentralized.
In practice:
● git is often used with a centralized
repository.
11. 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.
12. 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.
13. 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.
15. WordPress core development
● WordPress core development still uses SVN
:(
● It is possible to use git for core
development, and convert your patches to
SVN :)
18. Using Branches Best
● With git, branches are your friends.
● Branch early, branch often.
● Learn how interactively:http://pcottle.github.io/learnGitBranching/
19. 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.
21. 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.
22. 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
23. 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?
25. 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.
26. 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?
27. 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.
28. 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.
29. 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
30. 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
31. Thanks!
Thank you to Gregg Bense for organizing this
event
Thank you to the Fletcher Free Library for
hosting this event
33. 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/
Hinweis der Redaktion
Tutorial
Create a repository.
Change a file.
Add changes.
Commit changes.
View log.
Repeat w/ Source Tree