THE BUSINESS OF VERSION CONTROL
A BRIEF GUIDE TO WHAT, WHY AND HOW.
VERSION CONTROL
WHAT WE WILL COVER IN THIS PRESENTATION
‣What is version control
‣Why use version control
‣What we do instead of version control
‣What can we track with version control and why
‣Version control - how useful is it?
‣More detail on version control - looking at Git
‣Business of version control
‣Version control workflow
WHAT IS
VERSION
VERSION CONTROL IS A
SYSTEM THAT RECORDS
CHANGES TO A FILE OR SET OF
FILES OVER TIME SO THAT YOU
CAN RECALL SPECIFIC
VERSIONS LATER.Definition from https://git-scm.com/
VERSION CONTROL
* Version control is also known as and synonymous with source control
VERSION CONTROL DEFINITION
VERSION CONTROL
WHAT IS VERSION CONTROL?
‣ A tool for tracking changes and change information to files
‣A tool to help developers manage changes to code
‣ Track what you have changed and when in your files.
‣ Can track one file or many files in many folders
VERSION CONTROL
WHAT IS VERSION
CONTROL?
‣So, it’s just file management?
‣Not quite
Photo by Samuel Zeller on Unsplash
VERSION CONTROL
VERSION CONTROL - HOW USEFUL IS IT?
‣You may already use software, tools or services that offer a form of version control
‣WordPress - revisions are a form of version control
‣WordPress can even display the differences between revisions just like a
version control “diff” tool
‣A word processor / spreadsheet, in fact most apps we use - using the “undo” button
‣Wiki - all edits are tracked
WHY USE
VERSION
VERSION CONTROL
WHY USE VERSION CONTROL? FEATURE
BENEFITS
‣Manage the changes to themes, plugins, CSS, JavaScript, docs, readme text or
other files
‣Break down and manage changes into features, fixes, maintenance or just to test
‣Plan and track updates separately to production based code
‣Do this all within a development “safe house” - your local repository
VERSION CONTROL
WHY USE VERSION CONTROL? BUSINESS
BENEFITS
‣ Control changes to a theme, styles or application based on features
‣ Allow development to progress and using multiple developers
‣ Know exactly what changes you are applying to production after testing the same changes in pre-
production
‣ Businesses can be informed about the state of the software running in their applications
‣ Break each change down to the smallest part - and be able to home in on exactly where something
changed for the worse (or better)
‣ Hiring a developer? Ask if your developer knows how to integrate version control into the work they
do for you
Source: Icelandmag.is
VERSION CONTROL
USE A GO-BETWEEN FOLDER
VERSION CONTROL
FTP AND HOPE
‣FTP locally edited files to our
theme / plugin files on our server
(don’t forget the important file)
‣Copy them from live to local
machine, edit and copy them back
and hope (did you copy them all?)
‣Edit and hope directly (I’ve done
both above)
Source:www.wpwhitesecurity.com
VERSION CONTROL
SFTP?
‣ Secure FTP - same issues as above but the
traffic is encrypted
‣ Files copied securely, encrypted during the
journey
‣ However, no real way of tracking changes,
controlling changes or testing changes to your
business critical files.
VERSION CONTROL
CAN I JUST
USE
BEYOND
COMPARE?Beyond Compare shows you file
differences but does not manage
them for you
WHAT CAN WE TRACK WITH
VERSION CONTROL
Photo by Fabian Grohs on Unsplash
VERSION CONTROL
WHAT CAN WE TRACK WITH VERSION CONTROL?
‣WordPress - you can but not always the best approach (but WP Engine, Pantheon allow
you to do so to keep sites on the same version if needed)
‣WordPress theme, plugin - yes
‣Support files, JavaScript, CSS - yes
‣The book we could be writing: https://github.com/WordPress/book - sure, why not?
‣Documentation - some of Amazon’s AWS docs https://github.com/awsdocs/aws-step-
functions-developer-guide
‣WordPress database - no, not really
VERSION CONTROL
WHAT CAN WE TRACK WITH VERSION CONTROL?
▸MySQL is generally not tracked with a version control or source control tool
▸However, services/plugins do exist to help manage the stages of development
relevant to databases or perhaps offer the ability to take snapshots of databases
▸WP-CLI can be used to take database snapshots (and restore to your site)
throughout the development lifecycle
Can we track changes to a WordPress database with the same version control
tools?
VERSION CONTROL
SOURC
ETREE
(ATLAS
SIAN)Using a version
control GUI like this
can help visualize
changes to files in a
Git repository
VERSION CONTROL
VERSION CONTROL PRODUCTS
Use one of these popular source control / Version control products
LET’S TALK
ABOUT GIT
VERSION CONTROL
LETS TALK ABOUT GIT
‣This is my version control of choice
‣Much more detail here: https://git-scm.com/
‣Free, open source, fast, born in 2005
‣My experience with another version control product called SVN
‣The benefits and pitfalls of managing files tracked by both SVN and Git
VERSION CONTROL
VERSION CONTROL - GIT REPOSITORY
Repository
‣A folder that Git uses to store / manage changes to the files you ask it to track
‣Simply a place where the history of your work is stored
‣Git stores “commit objects” in the repository every time you tell it to
‣You store information about a change and Git stores the date and time along with
all its references to the change as a “Commit”
VERSION CONTROL
VERSION CONTROL - GIT COMMAND LINE
Set up Git using existing files / folders or start with an empty folder
‣Git init - initialize a Git repository on your local machine
‣Git add - add file(s) and/or folders to your repository for tracking from that point on
‣Git branch - separate out some changes to files in your repository
‣Git merge - combine changes from one branch into another
‣Git commit - commit a set of changes in your files to the Git repository
‣Git tag - assigned a number or name to a moment in time to your repository
VERSION CONTROL
VERSION CONTROL - GIT COMMAND LINE
‣Git diff - what changed?
‣Git status - what does Git think has happened since last commit
‣Git log - what commits have been logged and by whom (and much more…)
‣Git push - send committed changes to our repository
‣Git pull - get latest committed changes from our repository
VERSION CONTROL
VERSION CONTROL - GIT SERVICES
Git services and tools for hosting and managing repositories
▸Github
▸GitLab
▸BitBucket (from Atlassian)
GUI based Git tools / apps for managing repositories
▸SourceTree (from Atlassian)
▸GitTower (from Git Tower)
VERSION CONTROL
Photo by Pankaj Patel on Unsplash
VERSION CONTROL
Advantages
▸It’s the best
▸But takes time to be confident
▸Many command line parameters can embellish commit information within Git branches
▸Hugely configurable
Disadvantages
▸Can be difficult to learn beyond the basic commands
VERSION CONTROL - COMMAND LINE
TRACKING
CHANGES WITH
BASIC
BRANCHES
(source http://nvie.com/)
VERSION CONTROL
VERSION CONTROL - GIT CONCEPTS - BRANCHING
‣Master branch - best considered the “Branch of truth”
‣Always work in a branch other than master - best practice
‣AnyOtherBranch - a feature or fix. A developer or team of developers can work on a feature or fix
in one branch. Or each could branch again from that branch and work on their portion
‣Use branches to separate fixes or features - create branches from Master
‣Branches allow multiple developers to work on the same code
‣Merging branches can be difficult but Git is there to help smooth it out
‣Merge conflicts - when bringing together or merging branches into the repository
VERSION CONTROL
VERSION CONTROL - GIT CONCEPTS - BRANCHING
‣Develop branch - best used to test out a feature or multiple features
‣Based on Master branch which is always preferred to be production ready-
‣Once feature / fix is completed and tested then merge it in to Master
‣Keep Develop up to date by frequently merging in changes from Master
‣Remove features from Develop (subject to no other changes being made) by
resetting the beginning of the changes or “HEAD”
VERSION CONTROL
EXAMPLE GIT BRANCHES
Also shows hot fixes and feature
development
Source: Atlassian
VERSION CONTROL
VERSION CONTROL WORKFLOW
An example Git repository configuration and workflow using Git
Master branch -> production code -> runs on production site
Develop branch -> pre-production or dev code - runs on development site
This workflow example helps to keep our code in alignment with what is deployed in production
▸Allows us to work on new features or debug and rectify issues / fixes
▸Test out code improvements or new vendor scripts
▸Test out and combine features using our Develop branch
▸Play around with new ideas
▸Share improvements or code ideas between teams/developers
VERSION CONTROL
VERSION CONTROL WORKFLOW - GIT
$ Git init
$ Git add .
From this point on Git tracks all your
▸Changes
▸Deletions
▸Needs clarifications from you on additions
▸File renames
▸File additions
All in a local repository
VERSION CONTROL
VERSION CONTROL WORKFLOW - GIT
Commits
▸Details of a change or changes to files / folders in a repository - a snapshot
Conflicts
▸Changes to the same file by different developers or when merging branches can
cause conflict
▸Git tries to help you resolve but a conflict is a result of it not being able to
arbitrate safely
VERSION CONTROL
MERGE CONFLICTS
Conflicts
▸Changes to the same file by different
developers or when merging branches can
cause conflict
▸Git tries to help you resolve but a conflict is
a result of it not being able to arbitrate safely
▸Use your favorite editor to resolve conflicts
manually
VERSION CONTROL
FIX MERGE CONFLICTS
▸ Incoming change from master is what I’d like so
I would click “Accept Incoming Change”
VERSION CONTROL
VERSION CONTROL WORKFLOW - GIT
Branches
▸These help with feature separation
▸These allow multiple developers to work on the same project
▸Merge feature branches when ready into master or develop branches
VERSION CONTROL
VERSION CONTROL WORKFLOW - GIT
Tags
▸Mostly but not solely used for version numbering
▸A tag is always connected to / pointing to a commit - “a point in time”
THE BUSINESS OF
VERSION CONTROL
Photo by rawpixel on Unsplash
VERSION CONTROL
BUSINESS OF VERSION CONTROL
Think of it as a documented transaction between states in your code - adding value to the end product and
giving the developer complete flexibility
▸Use it if you can - or know it’s being used on your site
▸Think of it like an insurance policy
▸Manage and test changes
▸Like CMD-Z or CTRL-Z undo changes (and redo if needed) but with way more control
▸Have a history of all changes
▸Useful resource when onboarding with developers
▸Revisit previously aborted / paused features
VERSION CONTROL
BUSINESS OF VERSION CONTROL
Combine Git with GitHub for
▸Issue tracking
▸Project tracking
▸Code review
▸Link to project management tools like Trello
VERSION CONTROL
BUSINESS OF VERSION CONTROL
▸Embrace code standards
▸Foster collaboration - between owner and developer(s)
▸Encourage discussion on how something can be coded / developed / improved
Photo by David M
VERSION CONTROL
GIT INSIDE SVN
▸Working with WordPress.com VIP service means working with SVN
▸We put the SVN code from WordPress.com VIP in a folder that also shares the same
code from the Git repository we work on
▸Configure SVN to ignore Git and vice versa
▸Regular workflow in Git / GitHub, pull down updates from Git
▸Push updates to production using SVN whilst keeping both SVN and Git sources in sync
▸However, the newer VIP Go environment is Git based only
VERSION CONTROL
RESOURCES
Read and learn everything about Git
https://git-scm.com/
Collaborate with source code and other developers
https://github.com/
Visual source tools that support Git
https://www.atlassian.com/software/bitbucket/
https://www.git-tower.com/
Learning Git
https://try.github.io/
http://rogerdudler.github.io/git-guide/ - more on a Git workflow with examples
https://learngitbranching.js.org/ - learn about Git branching
VERSION CONTROL
SEAN HAYES
Lead developer at the Chicago Sun-Times
Worked with WordPress since 2008
Worked for agencies and corporations, solo and in teams
Contributed to WordPress core
Have a plugin in the WordPress plugin repository - Featured Image Admin Thumb
@seanchayes on Twitter
Connect with me on Linked in - https://www.linkedin.com/in/seanchayes
sean@emstarinc.com

Version control

  • 1.
    THE BUSINESS OFVERSION CONTROL A BRIEF GUIDE TO WHAT, WHY AND HOW.
  • 2.
    VERSION CONTROL WHAT WEWILL COVER IN THIS PRESENTATION ‣What is version control ‣Why use version control ‣What we do instead of version control ‣What can we track with version control and why ‣Version control - how useful is it? ‣More detail on version control - looking at Git ‣Business of version control ‣Version control workflow
  • 3.
  • 4.
    VERSION CONTROL ISA SYSTEM THAT RECORDS CHANGES TO A FILE OR SET OF FILES OVER TIME SO THAT YOU CAN RECALL SPECIFIC VERSIONS LATER.Definition from https://git-scm.com/ VERSION CONTROL * Version control is also known as and synonymous with source control VERSION CONTROL DEFINITION
  • 5.
    VERSION CONTROL WHAT ISVERSION CONTROL? ‣ A tool for tracking changes and change information to files ‣A tool to help developers manage changes to code ‣ Track what you have changed and when in your files. ‣ Can track one file or many files in many folders
  • 6.
    VERSION CONTROL WHAT ISVERSION CONTROL? ‣So, it’s just file management? ‣Not quite Photo by Samuel Zeller on Unsplash
  • 7.
    VERSION CONTROL VERSION CONTROL- HOW USEFUL IS IT? ‣You may already use software, tools or services that offer a form of version control ‣WordPress - revisions are a form of version control ‣WordPress can even display the differences between revisions just like a version control “diff” tool ‣A word processor / spreadsheet, in fact most apps we use - using the “undo” button ‣Wiki - all edits are tracked
  • 8.
  • 9.
    VERSION CONTROL WHY USEVERSION CONTROL? FEATURE BENEFITS ‣Manage the changes to themes, plugins, CSS, JavaScript, docs, readme text or other files ‣Break down and manage changes into features, fixes, maintenance or just to test ‣Plan and track updates separately to production based code ‣Do this all within a development “safe house” - your local repository
  • 10.
    VERSION CONTROL WHY USEVERSION CONTROL? BUSINESS BENEFITS ‣ Control changes to a theme, styles or application based on features ‣ Allow development to progress and using multiple developers ‣ Know exactly what changes you are applying to production after testing the same changes in pre- production ‣ Businesses can be informed about the state of the software running in their applications ‣ Break each change down to the smallest part - and be able to home in on exactly where something changed for the worse (or better) ‣ Hiring a developer? Ask if your developer knows how to integrate version control into the work they do for you
  • 11.
  • 12.
    VERSION CONTROL USE AGO-BETWEEN FOLDER
  • 13.
    VERSION CONTROL FTP ANDHOPE ‣FTP locally edited files to our theme / plugin files on our server (don’t forget the important file) ‣Copy them from live to local machine, edit and copy them back and hope (did you copy them all?) ‣Edit and hope directly (I’ve done both above) Source:www.wpwhitesecurity.com
  • 14.
    VERSION CONTROL SFTP? ‣ SecureFTP - same issues as above but the traffic is encrypted ‣ Files copied securely, encrypted during the journey ‣ However, no real way of tracking changes, controlling changes or testing changes to your business critical files.
  • 15.
    VERSION CONTROL CAN IJUST USE BEYOND COMPARE?Beyond Compare shows you file differences but does not manage them for you
  • 16.
    WHAT CAN WETRACK WITH VERSION CONTROL Photo by Fabian Grohs on Unsplash
  • 17.
    VERSION CONTROL WHAT CANWE TRACK WITH VERSION CONTROL? ‣WordPress - you can but not always the best approach (but WP Engine, Pantheon allow you to do so to keep sites on the same version if needed) ‣WordPress theme, plugin - yes ‣Support files, JavaScript, CSS - yes ‣The book we could be writing: https://github.com/WordPress/book - sure, why not? ‣Documentation - some of Amazon’s AWS docs https://github.com/awsdocs/aws-step- functions-developer-guide ‣WordPress database - no, not really
  • 18.
    VERSION CONTROL WHAT CANWE TRACK WITH VERSION CONTROL? ▸MySQL is generally not tracked with a version control or source control tool ▸However, services/plugins do exist to help manage the stages of development relevant to databases or perhaps offer the ability to take snapshots of databases ▸WP-CLI can be used to take database snapshots (and restore to your site) throughout the development lifecycle Can we track changes to a WordPress database with the same version control tools?
  • 19.
    VERSION CONTROL SOURC ETREE (ATLAS SIAN)Using aversion control GUI like this can help visualize changes to files in a Git repository
  • 20.
    VERSION CONTROL VERSION CONTROLPRODUCTS Use one of these popular source control / Version control products
  • 21.
  • 22.
    VERSION CONTROL LETS TALKABOUT GIT ‣This is my version control of choice ‣Much more detail here: https://git-scm.com/ ‣Free, open source, fast, born in 2005 ‣My experience with another version control product called SVN ‣The benefits and pitfalls of managing files tracked by both SVN and Git
  • 23.
    VERSION CONTROL VERSION CONTROL- GIT REPOSITORY Repository ‣A folder that Git uses to store / manage changes to the files you ask it to track ‣Simply a place where the history of your work is stored ‣Git stores “commit objects” in the repository every time you tell it to ‣You store information about a change and Git stores the date and time along with all its references to the change as a “Commit”
  • 24.
    VERSION CONTROL VERSION CONTROL- GIT COMMAND LINE Set up Git using existing files / folders or start with an empty folder ‣Git init - initialize a Git repository on your local machine ‣Git add - add file(s) and/or folders to your repository for tracking from that point on ‣Git branch - separate out some changes to files in your repository ‣Git merge - combine changes from one branch into another ‣Git commit - commit a set of changes in your files to the Git repository ‣Git tag - assigned a number or name to a moment in time to your repository
  • 25.
    VERSION CONTROL VERSION CONTROL- GIT COMMAND LINE ‣Git diff - what changed? ‣Git status - what does Git think has happened since last commit ‣Git log - what commits have been logged and by whom (and much more…) ‣Git push - send committed changes to our repository ‣Git pull - get latest committed changes from our repository
  • 26.
    VERSION CONTROL VERSION CONTROL- GIT SERVICES Git services and tools for hosting and managing repositories ▸Github ▸GitLab ▸BitBucket (from Atlassian) GUI based Git tools / apps for managing repositories ▸SourceTree (from Atlassian) ▸GitTower (from Git Tower)
  • 27.
    VERSION CONTROL Photo byPankaj Patel on Unsplash
  • 28.
    VERSION CONTROL Advantages ▸It’s thebest ▸But takes time to be confident ▸Many command line parameters can embellish commit information within Git branches ▸Hugely configurable Disadvantages ▸Can be difficult to learn beyond the basic commands VERSION CONTROL - COMMAND LINE
  • 29.
  • 30.
  • 31.
    VERSION CONTROL VERSION CONTROL- GIT CONCEPTS - BRANCHING ‣Master branch - best considered the “Branch of truth” ‣Always work in a branch other than master - best practice ‣AnyOtherBranch - a feature or fix. A developer or team of developers can work on a feature or fix in one branch. Or each could branch again from that branch and work on their portion ‣Use branches to separate fixes or features - create branches from Master ‣Branches allow multiple developers to work on the same code ‣Merging branches can be difficult but Git is there to help smooth it out ‣Merge conflicts - when bringing together or merging branches into the repository
  • 32.
    VERSION CONTROL VERSION CONTROL- GIT CONCEPTS - BRANCHING ‣Develop branch - best used to test out a feature or multiple features ‣Based on Master branch which is always preferred to be production ready- ‣Once feature / fix is completed and tested then merge it in to Master ‣Keep Develop up to date by frequently merging in changes from Master ‣Remove features from Develop (subject to no other changes being made) by resetting the beginning of the changes or “HEAD”
  • 33.
    VERSION CONTROL EXAMPLE GITBRANCHES Also shows hot fixes and feature development Source: Atlassian
  • 34.
    VERSION CONTROL VERSION CONTROLWORKFLOW An example Git repository configuration and workflow using Git Master branch -> production code -> runs on production site Develop branch -> pre-production or dev code - runs on development site This workflow example helps to keep our code in alignment with what is deployed in production ▸Allows us to work on new features or debug and rectify issues / fixes ▸Test out code improvements or new vendor scripts ▸Test out and combine features using our Develop branch ▸Play around with new ideas ▸Share improvements or code ideas between teams/developers
  • 35.
    VERSION CONTROL VERSION CONTROLWORKFLOW - GIT $ Git init $ Git add . From this point on Git tracks all your ▸Changes ▸Deletions ▸Needs clarifications from you on additions ▸File renames ▸File additions All in a local repository
  • 36.
    VERSION CONTROL VERSION CONTROLWORKFLOW - GIT Commits ▸Details of a change or changes to files / folders in a repository - a snapshot Conflicts ▸Changes to the same file by different developers or when merging branches can cause conflict ▸Git tries to help you resolve but a conflict is a result of it not being able to arbitrate safely
  • 37.
    VERSION CONTROL MERGE CONFLICTS Conflicts ▸Changesto the same file by different developers or when merging branches can cause conflict ▸Git tries to help you resolve but a conflict is a result of it not being able to arbitrate safely ▸Use your favorite editor to resolve conflicts manually
  • 38.
    VERSION CONTROL FIX MERGECONFLICTS ▸ Incoming change from master is what I’d like so I would click “Accept Incoming Change”
  • 39.
    VERSION CONTROL VERSION CONTROLWORKFLOW - GIT Branches ▸These help with feature separation ▸These allow multiple developers to work on the same project ▸Merge feature branches when ready into master or develop branches
  • 40.
    VERSION CONTROL VERSION CONTROLWORKFLOW - GIT Tags ▸Mostly but not solely used for version numbering ▸A tag is always connected to / pointing to a commit - “a point in time”
  • 41.
    THE BUSINESS OF VERSIONCONTROL Photo by rawpixel on Unsplash
  • 42.
    VERSION CONTROL BUSINESS OFVERSION CONTROL Think of it as a documented transaction between states in your code - adding value to the end product and giving the developer complete flexibility ▸Use it if you can - or know it’s being used on your site ▸Think of it like an insurance policy ▸Manage and test changes ▸Like CMD-Z or CTRL-Z undo changes (and redo if needed) but with way more control ▸Have a history of all changes ▸Useful resource when onboarding with developers ▸Revisit previously aborted / paused features
  • 43.
    VERSION CONTROL BUSINESS OFVERSION CONTROL Combine Git with GitHub for ▸Issue tracking ▸Project tracking ▸Code review ▸Link to project management tools like Trello
  • 44.
    VERSION CONTROL BUSINESS OFVERSION CONTROL ▸Embrace code standards ▸Foster collaboration - between owner and developer(s) ▸Encourage discussion on how something can be coded / developed / improved
  • 45.
  • 46.
    VERSION CONTROL GIT INSIDESVN ▸Working with WordPress.com VIP service means working with SVN ▸We put the SVN code from WordPress.com VIP in a folder that also shares the same code from the Git repository we work on ▸Configure SVN to ignore Git and vice versa ▸Regular workflow in Git / GitHub, pull down updates from Git ▸Push updates to production using SVN whilst keeping both SVN and Git sources in sync ▸However, the newer VIP Go environment is Git based only
  • 47.
    VERSION CONTROL RESOURCES Read andlearn everything about Git https://git-scm.com/ Collaborate with source code and other developers https://github.com/ Visual source tools that support Git https://www.atlassian.com/software/bitbucket/ https://www.git-tower.com/ Learning Git https://try.github.io/ http://rogerdudler.github.io/git-guide/ - more on a Git workflow with examples https://learngitbranching.js.org/ - learn about Git branching
  • 48.
    VERSION CONTROL SEAN HAYES Leaddeveloper at the Chicago Sun-Times Worked with WordPress since 2008 Worked for agencies and corporations, solo and in teams Contributed to WordPress core Have a plugin in the WordPress plugin repository - Featured Image Admin Thumb @seanchayes on Twitter Connect with me on Linked in - https://www.linkedin.com/in/seanchayes sean@emstarinc.com

Editor's Notes

  • #4 Can anyone define version control?
  • #5 Recalling specific versions or traveling back in time is useful here.
  • #6 Simply put it tracks file changes
  • #7 Weeeelll. More useful than that but it does help with organizing changes to files within folders
  • #8 Very useful, revert complicated code changes, restore a specific phrasing or layout of some text or code
  • #10 Be capable of planning changes, trying out changes, testing edge cases, all within a development safe house
  • #11 Brings in the chance to control changes to a website, application, theme, plugin. You can break down these into different repositories too and control each separately
  • #12 Instead of working without or against it learn how to use it and get tracking.
  • #14 Step away from the dangers associated with editing files using FTP (and hoping)
  • #20 A visual representation of a Git repository showing most recent changes, file and folder structure, details of change
  • #23 Why do I like Git, seem to be more resources available, more documentation and peer information
  • #34 Timeline is from left to right
  • #36 Switch to terminal perhaps? Set up blank folder, git init, touch file, edit file, save file, git status, git commit, add file, edit a file, git status, git diff, add folder, move tracked file to new folder