52
Version Uncontrolled! How to Manage Your Version Control Session 217 Tuesday, May 6,2015 10:50 – 11:30 am Track 2 Raastech, Inc. 2201 Cooperative Way, Suite 600 Herndon, VA 20171 +1-703-884-2223 [email protected]

Version Uncontrolled! How to Manage Your Version Control

Embed Size (px)

Citation preview

Page 1: Version Uncontrolled! How to Manage Your Version Control

Version Uncontrolled! How to Manage Your Version Control

Session  217  Tuesday,  May  6,2015  

10:50  –  11:30  am  Track  2  

Raastech, Inc. 2201 Cooperative Way, Suite 600 Herndon, VA 20171 +1-703-884-2223 [email protected]

Page 2: Version Uncontrolled! How to Manage Your Version Control

Slide 2 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

About Me

§  Harold Dost III @hdost

§  6+ years of Oracle Middleware experience

§  OCE (SOA Foundation Practitioner)

§  Oracle ACE Associate

§  From Michigan

§  blog.raastech.com

Page 3: Version Uncontrolled! How to Manage Your Version Control

Slide 3 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

About Raastech

§  Small systems integrator founded in 2009 §  Headquartered in the Washington DC area §  Specializes in Oracle Fusion Middleware §  Oracle Platinum Partner & Reseller

§  Oracle SOA Specialized §  100% of consultants are Oracle certified §  100% of consultants present at major Oracle conferences

§  100% of consultants have published books, whitepapers, or articles §  Oracle SOA Specialized – 1 in 1,500 worldwide §  Oracle Platinum Partner – 1 in 3,000 worldwide

Page 4: Version Uncontrolled! How to Manage Your Version Control

Slide 4 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Outline

1.  Introduction 2.  Version Control Systems 3.  Useful Version Control Commands 4.  Workflows 5.  The Deployment Cycle 6.  Branching 7.  Getting Your Team On Board 8.  Questions & Answers

Page 5: Version Uncontrolled! How to Manage Your Version Control

Slide 5 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 6: Version Uncontrolled! How to Manage Your Version Control

Slide 6 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Bias

§  I am biased towards Git

§  I have done my best to be neutral

Git Factoids §  Git  is  a  distributed  revision  control  system  with  an  emphasis  on  speed,  data  integrity,  and  support  for  distributed,  non-­‐linear  workflows.  

§  Git   was   iniHally   designed   and   developed   by   Linus   Torvalds   for   Linux   kernel  development  in  2005  

§  Git  is  the  most  widely  adopted  version  control  system  for  soLware  development.  

§  Git  is  freely  distributed  under  the  terms  of  the  GNU  General  Public  License  v2.  

Page 7: Version Uncontrolled! How to Manage Your Version Control

Slide 7 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Typical Large Corp Release Method

§  Developer creates code §  Developer unit tests code §  Code may get tested by 3rd party §  Code may get reviewed by 3rd party §  Code may get tested in a secondary environment to

ensure setups are correct §  Code gets deployed to Production §  Spot checks may be done

Page 8: Version Uncontrolled! How to Manage Your Version Control

Slide 8 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Where is the code?

§  Often developer commits code to trunk repeatedly

Page 9: Version Uncontrolled! How to Manage Your Version Control

Slide 9 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Advantages

§  Easy!

Page 10: Version Uncontrolled! How to Manage Your Version Control

Slide 10 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Pitfalls

§  Not Simple §  http://www.infoq.com/presentations/Simple-Made-Easy

§  http://www.slideshare.net/evandrix/simple-made-easy

§  Need people to remember or record in a tool which code version is to be deployed

§  After deployment version may be all but lost §  Could have tools in place, but those require additional

maintenance §  Places tracking outside of developer responsibility

Page 11: Version Uncontrolled! How to Manage Your Version Control

Slide 11 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 12: Version Uncontrolled! How to Manage Your Version Control

Slide 12 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Types of Version Control

§  Centralized

§  Distributed

Page 13: Version Uncontrolled! How to Manage Your Version Control

Slide 13 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Centralized Version Control

§  Relies on single repository

§  People check-out and check-in documents

§  Some locking may be used to prevent conflicts

§  Branches treated like folders

Repository  

Curly   Larry   Moe  

Page 14: Version Uncontrolled! How to Manage Your Version Control

Slide 14 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Corporate Behavior: Centralized

§  Merges are feared

§  Tendency towards committing only when absolutely necessary

§  Commits to trunk/master for everything

Page 15: Version Uncontrolled! How to Manage Your Version Control

Slide 15 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Centralized Version Control Software

Subversion  (SVN)  

hRp://subversion.Hgris.org  

Team  Founda=on  Server  (TFS)  

hRps://msdn.microsoL.com/en-­‐us/vstudio/ff637362.aspx  

Concurrent  Versioning  System  (CVS)  hRp://www.nongnu.org/cvs/  

Perforce(P4)  

hRp://www.perforce.com  

ClearCase  

hRp://www-­‐03.ibm.com/soLware/products/en/clearcase  

Page 16: Version Uncontrolled! How to Manage Your Version Control

Slide 16 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

SVN

§  Initial Release in 2000

§  An Apache Foundation Project

§  Mostly compatible successor to CVS

Page 17: Version Uncontrolled! How to Manage Your Version Control

Slide 17 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Distributed Version Control

§  Repositories are local

§  Peer-to-Peer

§  Exchange Patches

§  Branches are separate entities

Joe  

Curly  

Moe  

“Blessed”  Repo  

Page 18: Version Uncontrolled! How to Manage Your Version Control

Slide 18 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Distributed Version Control Software

Bazaar  

hRp://git-­‐scm.com/  

Page 19: Version Uncontrolled! How to Manage Your Version Control

Slide 19 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Git

§  Started in 2005 by Linus Torvalds to support Linux Kernel Development

§  Inspired by BitKeeper and Monotone

Page 20: Version Uncontrolled! How to Manage Your Version Control

Slide 20 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Using Git

Page 21: Version Uncontrolled! How to Manage Your Version Control

Slide 21 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 22: Version Uncontrolled! How to Manage Your Version Control

Slide 22 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Initialize a Repository

§  In SVN: §  HOWTO: Hosting a Subversion Repository

§  http://queens.db.toronto.edu/~nilesh/linux/subversion-howto/

§  In Git:

§  https://kovshenin.com/2011/howto-remote-shared-git-repository/

git init

-OR-

git init –bare test-repo.git

Page 23: Version Uncontrolled! How to Manage Your Version Control

Slide 23 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to retrieve a repository

§  In SVN:

§  In Git:

svn co https://host.com/path/repo

git clone https://host.com/path/repo.git

-OR-

git clone user@server:path/repo.git

Page 24: Version Uncontrolled! How to Manage Your Version Control

Slide 24 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to add files

§  In SVN:

§  In Git:

svn add test-file.txt

git add test-file.txt

Page 25: Version Uncontrolled! How to Manage Your Version Control

Slide 25 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to commit changes

§  In SVN:

§  In Git:

svn commit –m "Some Message"

git commit –m "Some Message"

Page 26: Version Uncontrolled! How to Manage Your Version Control

Slide 26 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to push changes

§  In SVN: §  Doesn’t make sense as it’s not distributed

§  In Git: git push

Page 27: Version Uncontrolled! How to Manage Your Version Control

Slide 27 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to branch

§  In SVN:

§  In Git:

svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Creating a private branch of /calc/trunk."

git branch my-calc-branch

-OR-

git checkout –b my-calc-branch # Takes you to the new branch

Page 28: Version Uncontrolled! How to Manage Your Version Control

Slide 28 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to change branches

§  In SVN:

§  In Git:

cd path/to/branch

git checkout my-calc-branch

Page 29: Version Uncontrolled! How to Manage Your Version Control

Slide 29 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

How to merge

§  In SVN:

§  In Git:

cd /path/to/repo/trunk

svn merge ../branches/my_branch/ # Merges changes in working copy

svn commit -m "Merge my_branch"

cd /path/to/repo

git merge my-branch # Merges Local Branches

git push # Pushes merge out to remote

Page 30: Version Uncontrolled! How to Manage Your Version Control

Slide 30 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 31: Version Uncontrolled! How to Manage Your Version Control

Slide 31 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Release Method: Environment Based

Development   Test   ProducHon  (trunk)  

F2   F3  F1  

Page 32: Version Uncontrolled! How to Manage Your Version Control

Slide 32 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Centralized Workflow

§  Commits are sequential

§  All users commit to the same branch

§  No guarantee of what is “production-ready”

§  Tagging not very useful

Page 33: Version Uncontrolled! How to Manage Your Version Control

Slide 33 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Centralized Workflow (Cont.)

§  Developer Checks out

§  Makes Changes

§  Commits

§  Some point in the future code ends up in development

Page 34: Version Uncontrolled! How to Manage Your Version Control

Slide 34 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Feature Workflow

§  Developers create branches for each feature

§  Features don’t get merged until it’s time for production

 

Page 35: Version Uncontrolled! How to Manage Your Version Control

Slide 35 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Feature Workflow (Cont.)

§  Developer branches from master/trunk

§  Makes changes

Page 36: Version Uncontrolled! How to Manage Your Version Control

Slide 36 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Release-based “Driessen” Workflow

§  Two primary branches §  Production

§  Development

§  Transient Personal Branches

§  Tagging Used Heavily

§  Manages for Hot Fixes

§  Release Branches

Credit:  Vincent  Driessen  

Page 37: Version Uncontrolled! How to Manage Your Version Control

Slide 37 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Release-based Workflow (Cont.)

§  Starts similar to feature workflow §  Features branches from develop

§  Hotfixes from master

§  Upon feature completion, merged back into develop

§  Once ready to do a release create a branch §  Only perform bug fixes

§  Release to production/master

Page 38: Version Uncontrolled! How to Manage Your Version Control

Slide 38 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 39: Version Uncontrolled! How to Manage Your Version Control

Slide 39 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Where?

§  Where should deployments come from?

Page 40: Version Uncontrolled! How to Manage Your Version Control

Slide 40 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

When?

§  Disclaimer: Established processes may prevent changing the timing of releases.

§  How often should I release?

§  When during the day should I release?

Page 41: Version Uncontrolled! How to Manage Your Version Control

Slide 41 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 42: Version Uncontrolled! How to Manage Your Version Control

Slide 42 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Purpose Driven Separation

§  Branch Types §  Feature – “feature/HAD/00001-some-new-feature”

§  Bug – “bug/HAD/010000-blue-screen-of-death-is-red”

§  Spike / Experimental

§  “spike/HAD/radical-new-things”

§  “exp/HAD/something-really-awesome”

§  Release – “release/1.5” or “release/20150507.1”

§  Tagging – “1.4” or “20150808.1”

Page 43: Version Uncontrolled! How to Manage Your Version Control

Slide 43 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 44: Version Uncontrolled! How to Manage Your Version Control

Slide 44 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Finding Time

§  Transition Slowly

§  Implement portions where possible

§  Start with keeping all new development into separate

Page 45: Version Uncontrolled! How to Manage Your Version Control

Slide 45 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Get Familiar With Tools and Process

§  SVN Tutorials §  http://www.tutorialspoint.com/svn/

§  GIT Book §  http://git-scm.com/book/en/v2/

Page 46: Version Uncontrolled! How to Manage Your Version Control

Slide 46 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Perform an Exercise

§  Go through a practice bug fix and feature release. §  Create Branches

§  Make gimmick changes

§  Go through the steps of a release

§  Code Change

§  Code Review

§  Release and merge

Page 47: Version Uncontrolled! How to Manage Your Version Control

Slide 47 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Introduce it at a team meeting

§  This can be useful whether or not the release process is decided at a team level.

Page 48: Version Uncontrolled! How to Manage Your Version Control

Slide 48 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Try process with a real change

§  Be diligent about the process

§  Follow it to production

§  Review the hiccups and try to iron them out.

§  Slowly add it to more changes.

Page 49: Version Uncontrolled! How to Manage Your Version Control

Slide 49 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Do a team exercise

§  If this exercise can show improved efficiency and code quality

Page 50: Version Uncontrolled! How to Manage Your Version Control

Slide 50 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Page 51: Version Uncontrolled! How to Manage Your Version Control

Slide 51 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Contact Information

§  Harold Dost III §  Senior Consultant

§  @hdost

§  [email protected]

Page 52: Version Uncontrolled! How to Manage Your Version Control

Slide 52 of 52 © Raastech, Inc. 2015 | All rights reserved. @Raastech

Resources

§  Atlassian. (2015). Comparing Workflows. Retrieved 2015, from Atlassian: https://www.atlassian.com/git/tutorials/comparing-workflows/

§  Bansal, N. (2011). HOWTO: Hosting a Subversion Repository. Retrieved 2015, from University Of Toronto: http://queens.db.toronto.edu/~nilesh/linux/subversion-howto/

§  Driessen, V. (2010). A successful Git branching model. Retrieved 2015, from Nvie: http://nvie.com/posts/a-successful-git-branching-model/

§  Git SCM. (2014). Git Book. Retrieved 2015, from Git SCM: http://git-scm.com/book/en/v2/

§  Kovshenin, K. (2011). How To Create a Remote Shared Git Repository. Retrieved 2015, from Kovshenin: https://kovshenin.com/2011/howto-remote-shared-git-repository/

§  Tutorials Point. (2014). SVN Tutorial. Retrieved 2015, from Tutorials Point: http://www.tutorialspoint.com/svn/