SlideShare a Scribd company logo
Developing with
                         WordPress and Git
                             Rob Miller • @robmil
                               Big Fish Design




Friday, 23 November 12                              1
An introduction



Friday, 23 November 12                     2
“Git”? Huh?
                         What’s that?




Friday, 23 November 12                  3
“Git”? Huh?
                           What’s that?

                    • A distributed version control system




Friday, 23 November 12                                       3
“Git”? Huh?
                           What’s that?

                    • A distributed version control system
                    • Free



Friday, 23 November 12                                       3
“Git”? Huh?
                           What’s that?

                    • A distributed version control system
                    • Free
                    • Open source


Friday, 23 November 12                                       3
“Git”? Huh?
                           What’s that?

                    • A distributed version control system
                    • Free
                    • Open source
                    • Popular

Friday, 23 November 12                                       3
A crash course in
                          version control


Friday, 23 November 12                       4
What is
                         version control?




Friday, 23 November 12                      5
What is
                         version control?
                    • Track changes made to source code




Friday, 23 November 12                                    5
What is
                         version control?
                    • Track changes made to source code
                    • Who did what and when




Friday, 23 November 12                                    5
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




Friday, 23 November 12                                         5
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
Why version control?




Friday, 23 November 12                  6
Why version control?
                    • “I just deleted a file by mistake — can we get
                         it back?”




Friday, 23 November 12                                                 6
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
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
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
Centralised
                         vs. distributed


Friday, 23 November 12                     7
Centralised
                         version control




Friday, 23 November 12                     8
Centralised
                           version control
                    • History stored in a central repository
                         running on a server




Friday, 23 November 12                                         8
Centralised
                           version control
                    • History stored in a central repository
                         running on a server

                    • Everyone commits to and from this
                         repository




Friday, 23 November 12                                         8
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, ClearCase



Friday, 23 November 12                                         8
Distributed
                         version control




Friday, 23 November 12                     9
Distributed
                         version control
                    • No central server




Friday, 23 November 12                     9
Distributed
                            version control
                    • No central server
                    • Every team member has a copy of the
                         entire repository and its history




Friday, 23 November 12                                       9
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.
                         Mercurial



Friday, 23 November 12                                       9
Advantages of DVCS




Friday, 23 November 12                10
Advantages of DVCS

                    • Redundancy




Friday, 23 November 12                10
Advantages of DVCS

                    • Redundancy
                    • Offline working



Friday, 23 November 12                  10
Advantages of DVCS

                    • Redundancy
                    • Offline working
                    • Speed


Friday, 23 November 12                  10
Git



Friday, 23 November 12         11
Git ≠ GitHub



Friday, 23 November 12                  12
Terminology, part one




Friday, 23 November 12                           13
Terminology, part one

                    • Commit




Friday, 23 November 12                           13
Terminology, part one

                    • Commit
                    • Branch



Friday, 23 November 12                           13
Terminology, part one

                    • Commit
                    • Branch
                    • Tag


Friday, 23 November 12                           13
Terminology, part one

                    • Commit
                    • Branch
                    • Tag
                    • Diff

Friday, 23 November 12                           13
Terminology, part one

                    • Commit
                    • Branch
                    • Tag
                    • Diff
                    • Commitish
Friday, 23 November 12                           13
Terminology, part two




Friday, 23 November 12                           14
Terminology, part two


                    • Pulling




Friday, 23 November 12                           14
Terminology, part two


                    • Pulling
                    • Pushing



Friday, 23 November 12                           14
Terminology, part two


                    • Pulling
                    • Pushing
                    • Cloning


Friday, 23 November 12                           14
What’s in a Git commit?




Friday, 23 November 12                             15
What’s in a Git commit?




Friday, 23 November 12                             15
What’s in a Git commit?




Friday, 23 November 12                             15
What’s in a Git commit?




Friday, 23 November 12                             15
What’s in a Git commit?




Friday, 23 November 12                             15
Branches




Friday, 23 November 12              16
Branches
                    • In Subversion, they’re basically useless




Friday, 23 November 12                                           16
Branches
                    • In Subversion, they’re basically useless
                    • In Git, they’re at the heart of almost
                         everything




Friday, 23 November 12                                           16
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




Friday, 23 November 12                                            16
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


Friday, 23 November 12                                            16
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 done

Friday, 23 November 12                                            16
Special branch




Friday, 23 November 12                    17
Special branch

                    • Git doesn’t force you to have any
                         particular branches




Friday, 23 November 12                                    17
Special branch

                    • Git doesn’t force you to have any
                         particular branches

                    • But by convention, master is your
                         stable branch




Friday, 23 November 12                                    17
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 it



Friday, 23 November 12                                    17
Branch commands




Friday, 23 November 12                     18
Branch commands
                    • git branch foo will create a branch
                         called “foo”.




Friday, 23 November 12                                      18
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
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 it


Friday, 23 November 12                                         18
Merging




Friday, 23 November 12             19
Merging

                    • Once you’re done with a branch, you
                         can merge it into another:
                         $ git checkout master
                         $ git merge --no-ff foo




Friday, 23 November 12                                      19
When should
                         you branch?




Friday, 23 November 12                 20
When should
                           you branch?

                    • For individual features




Friday, 23 November 12                          20
When should
                          you branch?

                    • For individual features
                    • What does that mean, though?



Friday, 23 November 12                               20
When should
                             you branch?

                    • For individual features
                    • What does that mean, though?
                    • Generally: anything that might be put
                         live independently




Friday, 23 November 12                                        20
Setting up
                         a repository


Friday, 23 November 12                  21
Friday, 23 November 12   22
$ git init




Friday, 23 November 12                22
Working
                         with a team


Friday, 23 November 12                 23
A typical team setup




Friday, 23 November 12                   24
A typical team setup

                         You




Friday, 23 November 12                   24
A typical team setup

                         You




          The rest of the team




Friday, 23 November 12                   24
A typical team setup
                                 Hub

                         You




          The rest of the team




Friday, 23 November 12                   24
A typical team setup
                                 Hub

                         You


                                       Staging
          The rest of the team




Friday, 23 November 12                           24
A typical team setup
                                 Hub

                         You           Production


                                        Staging
          The rest of the team




Friday, 23 November 12                              24
Hooks



Friday, 23 November 12           25
Friday, 23 November 12   26
• Scripts that run after certain events
                         — just like actions in WordPress




Friday, 23 November 12                                        26
• Scripts that run after certain events
                         — just like actions in WordPress

                    • Potential uses:




Friday, 23 November 12                                        26
• Scripts that run after certain events
                         — just like actions in WordPress

                    • Potential uses:
                     • Post a message in an IRC channel
                          when someone pushes




Friday, 23 November 12                                        26
• 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




Friday, 23 November 12                                        26
• 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 commits


Friday, 23 November 12                                        26
Git and WordPress



Friday, 23 November 12                       27
Things to exclude




Friday, 23 November 12                       28
Things to exclude

                    • wp-config.php




Friday, 23 November 12                       28
Things to exclude

                    • wp-config.php
                    • wp-uploads/* (or perhaps not…)



Friday, 23 November 12                                 28
Things to exclude

                    • wp-config.php
                    • wp-uploads/* (or perhaps not…)
                    • Anything that might conceivably be
                         different on live vs. development




Friday, 23 November 12                                       28
Image uploads




Friday, 23 November 12                   29
Image uploads

                    • Image uploads inevitably happen on
                         live




Friday, 23 November 12                                     29
Image uploads

                    • Image uploads inevitably happen on
                         live

                    • Are they content (so should be
                         excluded from Git)?




Friday, 23 November 12                                     29
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
Potential solutions




Friday, 23 November 12                         30
Potential solutions
                    • Ignore them — don’t have them in Git at all




Friday, 23 November 12                                              30
Potential solutions
                    • Ignore them — don’t have them in Git at all
                    • Periodically add them into Git from the live
                         server




Friday, 23 November 12                                               30
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




Friday, 23 November 12                                               30
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 images



Friday, 23 November 12                                               30
Plugin/core
                          upgrades




Friday, 23 November 12                 31
Plugin/core
                                upgrades
                    • If they happen on live, you’ll end up
                         with untracked files/uncommitted
                         changes to your live files




Friday, 23 November 12                                        31
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 it



Friday, 23 November 12                                          31
Solutions




Friday, 23 November 12               32
Solutions
                    • Disable upgrades/plugin installs on your live
                         sites, do upgrades locally, then deploy to live




Friday, 23 November 12                                                     32
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




Friday, 23 November 12                                                     32
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.php



Friday, 23 November 12                                                     32
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-git




Friday, 23 November 12                                                                       33
Git GUIs




Friday, 23 November 12              34
Git GUIs

                    • Use the command line first!




Friday, 23 November 12                              34
Git GUIs

                    • Use the command line first!
                    • But on Windows: Tortoise Git



Friday, 23 November 12                               34
Git GUIs

                    • Use the command line first!
                    • But on Windows: Tortoise Git
                    • On OS X: Tower, GitBox, Gitti


Friday, 23 November 12                                34
Git GUIs

                    • Use the command line first!
                    • But on Windows: Tortoise Git
                    • On OS X: Tower, GitBox, Gitti
                    • On Linux: giggle, gitg, QGit

Friday, 23 November 12                                34
And finally…




Friday, 23 November 12                  35
And finally…




Friday, 23 November 12                  35
And finally…
                    • Jeff’s leaving! :(




Friday, 23 November 12                       35
And finally…
                    • Jeff’s leaving! :(
                    • We’re hiring! :)




Friday, 23 November 12                       35
And finally…
                    • Jeff’s leaving! :(
                    • We’re hiring! :)
                    • Apply online:
                         http://bit.ly/SZJJ8v

                         or email:
                         rob@bigfish.co.uk




Friday, 23 November 12                          35

More Related Content

Recently uploaded (20)

PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Français Patch Tuesday - Juillet
Ivanti
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Français Patch Tuesday - Juillet
Ivanti
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 

Featured (20)

PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
PDF
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
PDF
Everything You Need To Know About ChatGPT
Expeed Software
 
PDF
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
PDF
Skeleton Culture Code
Skeleton Technologies
 
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
PDF
Content Methodology: A Best Practices Report (Webinar)
contently
 
PPTX
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
PDF
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
PDF
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
PDF
Getting into the tech field. what next
Tessa Mero
 
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
PDF
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Ad

Developing with WordPress and Git

  • 1. Developing with WordPress and Git Rob Miller • @robmil Big Fish Design Friday, 23 November 12 1
  • 3. “Git”? Huh? What’s that? Friday, 23 November 12 3
  • 4. “Git”? Huh? What’s that? • A distributed version control system Friday, 23 November 12 3
  • 5. “Git”? Huh? What’s that? • A distributed version control system • Free Friday, 23 November 12 3
  • 6. “Git”? Huh? What’s that? • A distributed version control system • Free • Open source Friday, 23 November 12 3
  • 7. “Git”? Huh? What’s that? • A distributed version control system • Free • Open source • Popular Friday, 23 November 12 3
  • 8. A crash course in version control Friday, 23 November 12 4
  • 9. What is version control? Friday, 23 November 12 5
  • 10. What is version control? • Track changes made to source code Friday, 23 November 12 5
  • 11. What is version control? • Track changes made to source code • Who did what and when Friday, 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 worked Friday, 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. distributed Friday, 23 November 12 7
  • 20. Centralised version control Friday, 23 November 12 8
  • 21. Centralised version control • History stored in a central repository running on a server Friday, 23 November 12 8
  • 22. Centralised version control • History stored in a central repository running on a server • Everyone commits to and from this repository Friday, 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, ClearCase Friday, 23 November 12 8
  • 24. Distributed version control Friday, 23 November 12 9
  • 25. Distributed version control • No central server Friday, 23 November 12 9
  • 26. Distributed version control • No central server • Every team member has a copy of the entire repository and its history Friday, 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. Mercurial Friday, 23 November 12 9
  • 28. Advantages of DVCS Friday, 23 November 12 10
  • 29. Advantages of DVCS • Redundancy Friday, 23 November 12 10
  • 30. Advantages of DVCS • Redundancy • Offline working Friday, 23 November 12 10
  • 31. Advantages of DVCS • Redundancy • Offline working • Speed Friday, 23 November 12 10
  • 33. Git ≠ GitHub Friday, 23 November 12 12
  • 34. Terminology, part one Friday, 23 November 12 13
  • 35. Terminology, part one • Commit Friday, 23 November 12 13
  • 36. Terminology, part one • Commit • Branch Friday, 23 November 12 13
  • 37. Terminology, part one • Commit • Branch • Tag Friday, 23 November 12 13
  • 38. Terminology, part one • Commit • Branch • Tag • Diff Friday, 23 November 12 13
  • 39. Terminology, part one • Commit • Branch • Tag • Diff • Commitish Friday, 23 November 12 13
  • 40. Terminology, part two Friday, 23 November 12 14
  • 41. Terminology, part two • Pulling Friday, 23 November 12 14
  • 42. Terminology, part two • Pulling • Pushing Friday, 23 November 12 14
  • 43. Terminology, part two • Pulling • Pushing • Cloning Friday, 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
  • 50. Branches • In Subversion, they’re basically useless Friday, 23 November 12 16
  • 51. Branches • In Subversion, they’re basically useless • In Git, they’re at the heart of almost everything Friday, 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 like Friday, 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 separate Friday, 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 done Friday, 23 November 12 16
  • 55. Special branch Friday, 23 November 12 17
  • 56. Special branch • Git doesn’t force you to have any particular branches Friday, 23 November 12 17
  • 57. Special branch • Git doesn’t force you to have any particular branches • But by convention, master is your stable branch Friday, 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 it Friday, 23 November 12 17
  • 59. Branch commands Friday, 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 it Friday, 23 November 12 18
  • 64. Merging • Once you’re done with a branch, you can merge it into another: $ git checkout master $ git merge --no-ff foo Friday, 23 November 12 19
  • 65. When should you branch? Friday, 23 November 12 20
  • 66. When should you branch? • For individual features Friday, 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 independently Friday, 23 November 12 20
  • 69. Setting up a repository Friday, 23 November 12 21
  • 71. $ git init Friday, 23 November 12 22
  • 72. Working with a team Friday, 23 November 12 23
  • 73. A typical team setup Friday, 23 November 12 24
  • 74. A typical team setup You Friday, 23 November 12 24
  • 75. A typical team setup You The rest of the team Friday, 23 November 12 24
  • 76. A typical team setup Hub You The rest of the team Friday, 23 November 12 24
  • 77. A typical team setup Hub You Staging The rest of the team Friday, 23 November 12 24
  • 78. A typical team setup Hub You Production Staging The rest of the team Friday, 23 November 12 24
  • 81. • Scripts that run after certain events — just like actions in WordPress Friday, 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 pushes Friday, 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 master Friday, 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 commits Friday, 23 November 12 26
  • 86. Git and WordPress Friday, 23 November 12 27
  • 87. Things to exclude Friday, 23 November 12 28
  • 88. Things to exclude • wp-config.php Friday, 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. development Friday, 23 November 12 28
  • 91. Image uploads Friday, 23 November 12 29
  • 92. Image uploads • Image uploads inevitably happen on live Friday, 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
  • 96. Potential solutions • Ignore them — don’t have them in Git at all Friday, 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 server Friday, 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 hook Friday, 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 images Friday, 23 November 12 30
  • 100. Plugin/core upgrades Friday, 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 files Friday, 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 it Friday, 23 November 12 31
  • 104. Solutions • Disable upgrades/plugin installs on your live sites, do upgrades locally, then deploy to live Friday, 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 live Friday, 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.php Friday, 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-git Friday, 23 November 12 33
  • 108. Git GUIs Friday, 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 Git Friday, 23 November 12 34
  • 111. Git GUIs • Use the command line first! • But on Windows: Tortoise Git • On OS X: Tower, GitBox, Gitti Friday, 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, QGit Friday, 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: [email protected] Friday, 23 November 12 35