Embracing Distributed Version Control

Post on 13-Jan-2015

1,355 views 2 download

Tags:

description

 

transcript

Embracing Distributed Version Control

How to Drastically Improve Collaboration, Experimentation,

Productivity, Freedom, Flexibility, Data Integrity and take two strokes off

of your golf game

Lets Talk About It

Open Forum • Ask questions• Ask for demonstrations  • Add opinions• Share experiences• Try it yourself

What's the Big Deal?

• Tools should mold to your process• Projects have lots of independent features• Feature isolation • "Major Milestone" vs. "Release Often"• "Only commit when its done" is limiting

The Basics

 

Centralized Version Control Systems• One centralized server with the revision database

o single point of failure• Clients checkout a working copy to their machine• Most operations happen on the server• Checkouts/Updates happen one directory at a time• Linear revision history (merges squash commits)• Every directory contains a "special folder"

 

Distributed Version Control Systems• Every client has a full revision history locally

o # backups == # clients o no need to be online

• All operations are local (except sharing)• Non-linear revision history• Network operations are compressed into packed

downloads • Working copy is independent of versioning system

Different to the Core

How Did We Get Here Again?

 

There Can Only Be One... or maybe two• Everyone has their own opinions• In the end choose what system fits best

o but whatever you do, choose a DVCS (at least for your local development)

• Today we will compare SVN and GIT

Lets Take a Walk... Side by SideSVN GIT

Obtain Code svn checkout <url> git clone <url>

Add Files svn add file1.php *.css git add file1.php *.css

Status svn status git status

Differences svn diff | less git diff

Restore File svn revert <path> git checkout <path>

Commit All Changes svn commit git commit -a

Get Latest Updates svn update git pull

Share Latest Edits git push

Branching

 

I've Branched Before... So What?

• With CVCS branching is used to separate major releases

• Branching is always followed by merging• Both tasks need to be easy and inexpensive

Branching is Hard... Or is it?

Tasks1.Obtain the source code– Create Branch– Switch Branch– Merge Branch

Branching is Hard... Or is it?

        REPO=http://svn.php.net/repository/php/php-src/1. svn checkout $REPO/trunk  (10 minutes)– svn copy $REPO/branches/PHP_5_3 $REPO/branches/PHP_5_5  (4

minutes)– svn switch $REPO/branches/PHP_5_5   (50 seconds)– svn merge -r 20:HEAD $REPO/branches/PHP_5_3 (claw your eyes out)

 Total Time: ~15 minutes + clawing your eyes out Total Time Branching: ~5 minutes  

Branching is Hard... Or is it?

 1.git clone git://github.com/php/php-src.git  (3

minutes) – git branch PHP_5_5 origin/PHP_5_3  (5

milliseconds)– git checkout PHP_5_5   (2 seconds)– git merge origin/PHP_5_3   (1 second) Total Time: ~3 minutesTotal Time Branching: ~3 seconds

OK. So Branching Is Easy... Now What?• Cheap and easy branching fundamentally changes

the way you approach development• Everything is done on a branch• Issue isolation is now a reality

Every Change Has Its Place in a BranchYou can use any branching style you choose. Here's an example:• master

o also referred to as trunk• hotfix-X

o quick fixes to master • develop

o integration point for all completed feature branches

• feature-Yo every discreet issue is worked on in a feature

branch

complete walk-through: http://nvie.com/git-model

Workflow

 

Your Centralized Workflow

With Centralized Version Control Systems, your workflow will always look like this.

image source: http://whygitisbetterthanx.com

Chose Your Own Adventure WorkflowWith Distributed Version Control Systems you can morph your workflow to meet your needs. You can do it the same...

image source: http://whygitisbetterthanx.com

Or It Can Work Like This...

Integration Manager Approach• Useful for small to large teams• Integration manager merges all feature branches

into mainline

Or It Can Work Like This...

Dictator and Lieutenants• Useful for large teams• Team Leaders curate new feature branches into

production ready state • Dictator has final say and merged into mainline

Migration & Integration

 

Dipping Your Toes in the Water

• Use your favorite DVCS with most other VCS repositories

• Push and Pull changes between systems 

Diving in Head First

• Import entire history/branches from legacy systems• Rinse & repeat: make you have everything before

you switch

References

GIT • http://git-scm.com/course/svn.html• http://whygitisbetterthanx.com/• http://nvie.com/git-model/ • http://progit.org/book/ • http://gitref.org/ • http://gitready.com/

 Mercurial • http://hginit.com/

Get In Touch

Nowell Strite• Twitter: nowells• Email: nowell@strite.org

 Matthew Weier O'Phinney• Twitter: weierophinney• Email: matthew@weierophinney.net