Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Version Control

Or distributed time machines to create better software


Nikhil Marathe
nsm.nikhil@gmail.com

Software Development Cycle


Design Release!
(once in a while)

Code

Test

Software Development Cycle


Scaled by People Time

denny :p

Enter Version Control Systems

Centralized

Distributed

Clones and Checkouts


get your own copy of the code

Subversion checks out


svn co https://myawesome.com/pristine/trunk myawesome

With distributed you clone


git clone https://awesome2.org/awesome2/awesome2.git hg clone https://hgbasedproject.org/bazinga/

Clones vs. Checkouts


Introduce a little anarchy...

Subversion aside
initial repository creation

$ svnadmin create\ /path/repo

+
a few more steps

/path/repo | |-branches |-awesome-1.0.2/ `-bazinga-0.5.0/ |-tags `-trunk |-awesome/ |-bazinga/

Commits
hg/svn/git commit

Git has the concept of a staging area which adds better control on the versioning, and gives more freedom while editing, but introduces a two step commit process. hg has a similar extensions called crecord

Hack hack hack

Revisions
Way to identify a snapshot of the code SVN - 1,2,3,4......1019123.... Git/Hg SHA1 hash eg. a954467190e7ab871433e8571da75e1768b6b583 Special revisions such as HEAD, tip, ORIGIN

Collaboration - push & pull


ALICE (private) ALICE (public) master

BOB
(public)

BOB
(private)

Commit

Pull

Push

Recovering from mistakes


rollbacks and reverts

diff and merge

Usual workflow
on a nice new day update/pull in changes from others see whats new, resolve any conflicts work on your feature hack hack hack keep committing atomically push to public/central repository asend a pull request if you want blog about cool new feature

That should keep you occupied for several months


Or - you don't really understand it until you do it.

Good practices
Commit frequently Commit atomically Put in good commit messages No binary/generated files in the repo Never, never, never, never, never, ever break the build

What I didn't cover


Repository administration, staging area, stash, rebase, shelve, Mercurial Queues Diff formats, Resolving merge conflicts

That's all Folks!


Use it for your current project, and every one after that Get yourself an account on bitbucket.org for Hg Or use code.google.com/hosting/ with svn or Hg No point in using Git in college since the ports are blocked SVN - subversion.tigris.org Mercurial - mercurial.selenic.com Git - git-scm.org The SVN book svnbook.red-bean.com The Hg book hgbook.red-bean.com The Git Parable http://tom.preston-werner.com/2009/05/19/the-gitparable.html

You might also like