Version Uncontrolled! How to Manage Your Version Control
Session 217 Tuesday, April 14,2015
3:15 - 4:15 pm Room Banyan B
Raastech, Inc. 2201 Cooperative Way, Suite 600 Herndon, VA 20171 +1-703-884-2223 [email protected]
Slide 2 of 53 © 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
Slide 3 of 53 © 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
Slide 4 of 53 © 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
Slide 6 of 53 © 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 initially designed and developed by Linus Torvalds for Linux kernel development in 2005
Git is the most widely adopted version control system for software development.
Git is freely distributed under the terms of the GNU General Public License v2.
Slide 7 of 53 © 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
Slide 8 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Where is the code?
Often developer commits code to trunk repeatedly
Slide 10 of 53 © 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
Slide 12 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Types of Version Control
Centralized
Distributed
Slide 13 of 53 © 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
Slide 14 of 53 © 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
Slide 15 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Centralized Version Control Software
Subversion (SVN)
http://subversion.tigris.org
Team Foundation Server (TFS)
https://msdn.microsoft.com/en-us/vstudio/ff637362.aspx
Concurrent Versioning System (CVS) http://www.nongnu.org/cvs/
Perforce(P4)
http://www.perforce.com
ClearCase
http://www-03.ibm.com/software/products/en/clearcase
Slide 16 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
SVN
Initial Release in 2000
An Apache Foundation Project
Mostly compatible successor to CVS
Slide 17 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Distributed Version Control
Repositories are local
Peer-to-Peer
Exchange Patches
Branches are separate
entity
Joe
Curly
Moe
“Blessed” Repo
Slide 18 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Distributed Version Control Software
Bazaar
http://git-scm.com/
Slide 19 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Git
Started in 2005 by Linus Torvalds to support Linux
Kernel Development
Inspired by BitKeeper and Monotone
Slide 22 of 53 © 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
Slide 23 of 53 © 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
Slide 24 of 53 © 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
Slide 25 of 53 © 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"
Slide 26 of 53 © 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
Slide 27 of 53 © 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
Slide 28 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
How to change branches
In SVN:
In Git:
cd path/to/branch
git checkout my-calc-branch
Slide 29 of 53 © 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
Slide 31 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Release Method 1: Environment Based
Development Test Production
(trunk)
F2 F3 F1
Slide 32 of 53 © 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
Slide 33 of 53 © 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
Slide 34 of 53 © 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
Slide 35 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Feature Workflow (Cont.)
Developer branches from master/trunk
Makes changes
Slide 36 of 53 © 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
Slide 37 of 53 © 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
Slide 39 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Where?
Where should deployments come from?
Slide 40 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
When?
“Disclaimer about how established processes may
prevent changing the timing and the effects of testing on
this.”
How often should I release?
When during the day should I release?
Slide 42 of 53 © 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”
Slide 44 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Finding Time
Transition Slowly
Implement portions where possible
Start with keeping all new development into separate
Slide 45 of 53 © 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/
Slide 46 of 53 © 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
Slide 47 of 53 © 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.
Slide 48 of 53 © 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.
Slide 49 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Do a team exercise
If this exercise can show improved efficiency and code
quality
Slide 51 of 53 © Raastech, Inc. 2015 | All rights reserved. @Raastech
Contact Information
Harold Dost III
Senior Consultant
@hdost
Slide 52 of 53 © 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/