Developing with WordPress and Git
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Developing with WordPress and Git

  • 1,406 views
Uploaded on

A talk given at the Wordpress London meetup about version control, Git, and how to most effectively use Git with WordPress.

A talk given at the Wordpress London meetup about version control, Git, and how to most effectively use Git with WordPress.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,406
On Slideshare
1,401
From Embeds
5
Number of Embeds
1

Actions

Shares
Downloads
9
Comments
0
Likes
1

Embeds 5

https://twitter.com 5

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Developing with WordPress and Git Rob Miller • @robmil Big Fish DesignFriday, 23 November 12 1
  • 2. An introductionFriday, 23 November 12 2
  • 3. “Git”? Huh? What’s that?Friday, 23 November 12 3
  • 4. “Git”? Huh? What’s that? • A distributed version control systemFriday, 23 November 12 3
  • 5. “Git”? Huh? What’s that? • A distributed version control system • FreeFriday, 23 November 12 3
  • 6. “Git”? Huh? What’s that? • A distributed version control system • Free • Open sourceFriday, 23 November 12 3
  • 7. “Git”? Huh? What’s that? • A distributed version control system • Free • Open source • PopularFriday, 23 November 12 3
  • 8. A crash course in version controlFriday, 23 November 12 4
  • 9. What is version control?Friday, 23 November 12 5
  • 10. What is version control? • Track changes made to source codeFriday, 23 November 12 5
  • 11. What is version control? • Track changes made to source code • Who did what and whenFriday, 23 November 12 5
  • 12. What is version control? • Track changes made to source code • Who did what and when • When things break, revert to the point when it last workedFriday, 23 November 12 5
  • 13. What is version control? • Track changes made to source code • Who did what and when • When things break, revert to the point when it last worked • Like Time Machine for your website’s code (but not database/content…)Friday, 23 November 12 5
  • 14. Why version control?Friday, 23 November 12 6
  • 15. Why version control? • “I just deleted a file by mistake — can we get it back?”Friday, 23 November 12 6
  • 16. Why version control? • “I just deleted a file by mistake — can we get it back?” • “I need to know who made this change — can we find out?”Friday, 23 November 12 6
  • 17. Why version control? • “I just deleted a file by mistake — can we get it back?” • “I need to know who made this change — can we find out?” • “That feature just broke the site — can we revert it?”Friday, 23 November 12 6
  • 18. Why version control? • “I just deleted a file by mistake — can we get it back?” • “I need to know who made this change — can we find out?” • “That feature just broke the site — can we revert it?” • “There’s a bug that didn’t use to exist. When was it introduced?”Friday, 23 November 12 6
  • 19. Centralised vs. distributedFriday, 23 November 12 7
  • 20. Centralised version controlFriday, 23 November 12 8
  • 21. Centralised version control • History stored in a central repository running on a serverFriday, 23 November 12 8
  • 22. Centralised version control • History stored in a central repository running on a server • Everyone commits to and from this repositoryFriday, 23 November 12 8
  • 23. Centralised version control • History stored in a central repository running on a server • Everyone commits to and from this repository • Examples: CVS, Subversion (SVN), Perforce, ClearCaseFriday, 23 November 12 8
  • 24. Distributed version controlFriday, 23 November 12 9
  • 25. Distributed version control • No central serverFriday, 23 November 12 9
  • 26. Distributed version control • No central server • Every team member has a copy of the entire repository and its historyFriday, 23 November 12 9
  • 27. Distributed version control • No central server • Every team member has a copy of the entire repository and its history • Git isn’t the only option — e.g. MercurialFriday, 23 November 12 9
  • 28. Advantages of DVCSFriday, 23 November 12 10
  • 29. Advantages of DVCS • RedundancyFriday, 23 November 12 10
  • 30. Advantages of DVCS • Redundancy • Offline workingFriday, 23 November 12 10
  • 31. Advantages of DVCS • Redundancy • Offline working • SpeedFriday, 23 November 12 10
  • 32. GitFriday, 23 November 12 11
  • 33. Git ≠ GitHubFriday, 23 November 12 12
  • 34. Terminology, part oneFriday, 23 November 12 13
  • 35. Terminology, part one • CommitFriday, 23 November 12 13
  • 36. Terminology, part one • Commit • BranchFriday, 23 November 12 13
  • 37. Terminology, part one • Commit • Branch • TagFriday, 23 November 12 13
  • 38. Terminology, part one • Commit • Branch • Tag • DiffFriday, 23 November 12 13
  • 39. Terminology, part one • Commit • Branch • Tag • Diff • CommitishFriday, 23 November 12 13
  • 40. Terminology, part twoFriday, 23 November 12 14
  • 41. Terminology, part two • PullingFriday, 23 November 12 14
  • 42. Terminology, part two • Pulling • PushingFriday, 23 November 12 14
  • 43. Terminology, part two • Pulling • Pushing • CloningFriday, 23 November 12 14
  • 44. What’s in a Git commit?Friday, 23 November 12 15
  • 45. What’s in a Git commit?Friday, 23 November 12 15
  • 46. What’s in a Git commit?Friday, 23 November 12 15
  • 47. What’s in a Git commit?Friday, 23 November 12 15
  • 48. What’s in a Git commit?Friday, 23 November 12 15
  • 49. BranchesFriday, 23 November 12 16
  • 50. Branches • In Subversion, they’re basically uselessFriday, 23 November 12 16
  • 51. Branches • In Subversion, they’re basically useless • In Git, they’re at the heart of almost everythingFriday, 23 November 12 16
  • 52. Branches • In Subversion, they’re basically useless • In Git, they’re at the heart of almost everything • Juggle as many different versions of your code as you likeFriday, 23 November 12 16
  • 53. Branches • In Subversion, they’re basically useless • In Git, they’re at the heart of almost everything • Juggle as many different versions of your code as you like • Keep all your features nice and separateFriday, 23 November 12 16
  • 54. Branches • In Subversion, they’re basically useless • In Git, they’re at the heart of almost everything • Juggle as many different versions of your code as you like • Keep all your features nice and separate • Merge painlessly once you’re doneFriday, 23 November 12 16
  • 55. Special branchFriday, 23 November 12 17
  • 56. Special branch • Git doesn’t force you to have any particular branchesFriday, 23 November 12 17
  • 57. Special branch • Git doesn’t force you to have any particular branches • But by convention, master is your stable branchFriday, 23 November 12 17
  • 58. Special branch • Git doesn’t force you to have any particular branches • But by convention, master is your stable branch • Branch from it; merge to it; your releases are taken from itFriday, 23 November 12 17
  • 59. Branch commandsFriday, 23 November 12 18
  • 60. Branch commands • git branch foo will create a branch called “foo”.Friday, 23 November 12 18
  • 61. Branch commands • git branch foo will create a branch called “foo”. • git checkout bar will switch to the branch called “bar”Friday, 23 November 12 18
  • 62. Branch commands • git branch foo will create a branch called “foo”. • git checkout bar will switch to the branch called “bar” • git branch -d foo will delete a branch if you change your mind about itFriday, 23 November 12 18
  • 63. MergingFriday, 23 November 12 19
  • 64. Merging • Once you’re done with a branch, you can merge it into another: $ git checkout master $ git merge --no-ff fooFriday, 23 November 12 19
  • 65. When should you branch?Friday, 23 November 12 20
  • 66. When should you branch? • For individual featuresFriday, 23 November 12 20
  • 67. When should you branch? • For individual features • What does that mean, though?Friday, 23 November 12 20
  • 68. When should you branch? • For individual features • What does that mean, though? • Generally: anything that might be put live independentlyFriday, 23 November 12 20
  • 69. Setting up a repositoryFriday, 23 November 12 21
  • 70. Friday, 23 November 12 22
  • 71. $ git initFriday, 23 November 12 22
  • 72. Working with a teamFriday, 23 November 12 23
  • 73. A typical team setupFriday, 23 November 12 24
  • 74. A typical team setup YouFriday, 23 November 12 24
  • 75. A typical team setup You The rest of the teamFriday, 23 November 12 24
  • 76. A typical team setup Hub You The rest of the teamFriday, 23 November 12 24
  • 77. A typical team setup Hub You Staging The rest of the teamFriday, 23 November 12 24
  • 78. A typical team setup Hub You Production Staging The rest of the teamFriday, 23 November 12 24
  • 79. HooksFriday, 23 November 12 25
  • 80. Friday, 23 November 12 26
  • 81. • Scripts that run after certain events — just like actions in WordPressFriday, 23 November 12 26
  • 82. • Scripts that run after certain events — just like actions in WordPress • Potential uses:Friday, 23 November 12 26
  • 83. • Scripts that run after certain events — just like actions in WordPress • Potential uses: • Post a message in an IRC channel when someone pushesFriday, 23 November 12 26
  • 84. • Scripts that run after certain events — just like actions in WordPress • Potential uses: • Post a message in an IRC channel when someone pushes • Deploy to the live site when someone pushes on masterFriday, 23 November 12 26
  • 85. • Scripts that run after certain events — just like actions in WordPress • Potential uses: • Post a message in an IRC channel when someone pushes • Deploy to the live site when someone pushes on master • Run a syntax checker/strip whitespace/etc. before commitsFriday, 23 November 12 26
  • 86. Git and WordPressFriday, 23 November 12 27
  • 87. Things to excludeFriday, 23 November 12 28
  • 88. Things to exclude • wp-config.phpFriday, 23 November 12 28
  • 89. Things to exclude • wp-config.php • wp-uploads/* (or perhaps not…)Friday, 23 November 12 28
  • 90. Things to exclude • wp-config.php • wp-uploads/* (or perhaps not…) • Anything that might conceivably be different on live vs. developmentFriday, 23 November 12 28
  • 91. Image uploadsFriday, 23 November 12 29
  • 92. Image uploads • Image uploads inevitably happen on liveFriday, 23 November 12 29
  • 93. Image uploads • Image uploads inevitably happen on live • Are they content (so should be excluded from Git)?Friday, 23 November 12 29
  • 94. Image uploads • Image uploads inevitably happen on live • Are they content (so should be excluded from Git)? • Or are they layout/template related (so should be included in Git)?Friday, 23 November 12 29
  • 95. Potential solutionsFriday, 23 November 12 30
  • 96. Potential solutions • Ignore them — don’t have them in Git at allFriday, 23 November 12 30
  • 97. Potential solutions • Ignore them — don’t have them in Git at all • Periodically add them into Git from the live serverFriday, 23 November 12 30
  • 98. Potential solutions • Ignore them — don’t have them in Git at all • Periodically add them into Git from the live server • Automate the adding of them e.g. with a WordPress hookFriday, 23 November 12 30
  • 99. Potential solutions • Ignore them — don’t have them in Git at all • Periodically add them into Git from the live server • Automate the adding of them e.g. with a WordPress hook • Which solution depends on the nature of your imagesFriday, 23 November 12 30
  • 100. Plugin/core upgradesFriday, 23 November 12 31
  • 101. Plugin/core upgrades • If they happen on live, you’ll end up with untracked files/uncommitted changes to your live filesFriday, 23 November 12 31
  • 102. Plugin/core upgrades • If they happen on live, you’ll end up with untracked files/uncommitted changes to your live files • Doing them on live is insane regardless, so it makes double sense to stop doing itFriday, 23 November 12 31
  • 103. SolutionsFriday, 23 November 12 32
  • 104. Solutions • Disable upgrades/plugin installs on your live sites, do upgrades locally, then deploy to liveFriday, 23 November 12 32
  • 105. Solutions • Disable upgrades/plugin installs on your live sites, do upgrades locally, then deploy to live • Remove install_plugins, install_themes, update_plugins, update_themes, update_core capabilities from your users on liveFriday, 23 November 12 32
  • 106. Solutions • Disable upgrades/plugin installs on your live sites, do upgrades locally, then deploy to live • Remove install_plugins, install_themes, update_plugins, update_themes, update_core capabilities from your users on live • define(DISALLOW_FILE_EDIT, true); in your live wp-config.phpFriday, 23 November 12 32
  • 107. Useful resources • “Think Like a Git”: http://think-like-a-git.net/ • GitRef: http://gitref.org/ • ProGit: http://git-scm.com/book • Useful Git tips: http://mislav.uniqpath.com/2010/07/git-tips/ • “So, I’ve tried Git” by Ozh http://planetozh.com/blog/2012/11/so- ive-tried-git-and-its/ • Migrating an SVN repo to Git: http://john.albin.net/git/convert- subversion-to-gitFriday, 23 November 12 33
  • 108. Git GUIsFriday, 23 November 12 34
  • 109. Git GUIs • Use the command line first!Friday, 23 November 12 34
  • 110. Git GUIs • Use the command line first! • But on Windows: Tortoise GitFriday, 23 November 12 34
  • 111. Git GUIs • Use the command line first! • But on Windows: Tortoise Git • On OS X: Tower, GitBox, GittiFriday, 23 November 12 34
  • 112. Git GUIs • Use the command line first! • But on Windows: Tortoise Git • On OS X: Tower, GitBox, Gitti • On Linux: giggle, gitg, QGitFriday, 23 November 12 34
  • 113. And finally…Friday, 23 November 12 35
  • 114. And finally…Friday, 23 November 12 35
  • 115. And finally… • Jeff’s leaving! :(Friday, 23 November 12 35
  • 116. And finally… • Jeff’s leaving! :( • We’re hiring! :)Friday, 23 November 12 35
  • 117. And finally… • Jeff’s leaving! :( • We’re hiring! :) • Apply online: http://bit.ly/SZJJ8v or email: rob@bigfish.co.ukFriday, 23 November 12 35