37
Version Control SNUG TechTalk SciNet www.scinet.utoronto.ca University of Toronto Toronto, Canada October 13, 2010

Version Control - University of Toronto

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Version Control - University of Toronto

Version Control

SNUG TechTalk

SciNetwww.scinet.utoronto.caUniversity of Toronto

Toronto, Canada

October 13, 2010

Page 2: Version Control - University of Toronto

Outline

1 Version Control

2 Software

3 Examples

Page 3: Version Control - University of Toronto

Version Control

What is it?

A tool for managing changes in a set of files.

Figuring out who broke what where and when.

Why Do it?

Collaboration

Organization

Track Changes

Faster Development

Reduce Errors

Page 4: Version Control - University of Toronto

Version Control

What is it?

A tool for managing changes in a set of files.

Figuring out who broke what where and when.

Why Do it?

Collaboration

Organization

Track Changes

Faster Development

Reduce Errors

Page 5: Version Control - University of Toronto

Version Control

What is it?

A tool for managing changes in a set of files.

Figuring out who broke what where and when.

Why Do it?

Collaboration

Organization

Track Changes

Faster Development

Reduce Errors

Page 6: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 7: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 8: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 9: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 10: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 11: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 12: Version Control - University of Toronto

CollaborationWith others and yourself

Questions

What if two (or more) people want to edit the same file at thesame time?

What if you work on SciNet and on your own computer?

Answers

Option 1: make them take turns

But then only one person can be working at any timeAnd how do you enforce the rule?

Option 2: patch up differences afterwards

Requires a lot of re-workingStuff always gets lost

Option 3: Version Control

Page 13: Version Control - University of Toronto

Organize and Track Changes

Question

Want to undo changes to a file

Start work, realize it’s the wrong approach, want to get backto starting pointLike ”undo” in an editor......but keep the whole history of every file, forever

Also want to be able to see who changed what, when

The best way to find out how something works is often to askthe person who wrote it

Answer

Version Control

Page 14: Version Control - University of Toronto

Organize and Track Changes

Question

Want to undo changes to a file

Start work, realize it’s the wrong approach, want to get backto starting pointLike ”undo” in an editor......but keep the whole history of every file, forever

Also want to be able to see who changed what, when

The best way to find out how something works is often to askthe person who wrote it

Answer

Version Control

Page 15: Version Control - University of Toronto

Organize and Track Changes

Question

Want to undo changes to a file

Start work, realize it’s the wrong approach, want to get backto starting pointLike ”undo” in an editor......but keep the whole history of every file, forever

Also want to be able to see who changed what, when

The best way to find out how something works is often to askthe person who wrote it

Answer

Version Control

Page 16: Version Control - University of Toronto

Organize and Track Changes

Question

Want to undo changes to a file

Start work, realize it’s the wrong approach, want to get backto starting pointLike ”undo” in an editor......but keep the whole history of every file, forever

Also want to be able to see who changed what, when

The best way to find out how something works is often to askthe person who wrote it

Answer

Version Control

Page 17: Version Control - University of Toronto

How it Works

Page 18: Version Control - University of Toronto

How it Works

Page 19: Version Control - University of Toronto

How it Works

Page 20: Version Control - University of Toronto

How it Works

Page 21: Version Control - University of Toronto

How it Works

Page 22: Version Control - University of Toronto

How it Works

Page 23: Version Control - University of Toronto

How it Works

Page 24: Version Control - University of Toronto

How it Works

Page 25: Version Control - University of Toronto

How it Works

Resolving Conflicts: Optimistic Concurrency

Milk<<<<<<<Cheese=======Hot Dog>>>>>>>Juice

Page 26: Version Control - University of Toronto

What to Use

Software

Open Source

Subversion, CVS, RCSGit, Mercurial, Bazaar

Commercial

Perforce, ClearCase

available as modules on SciNet

Page 27: Version Control - University of Toronto

Software

Subversion (svn)

Centralized Version Control

Replaces CVS

Lots of web and GUI integration

Users: GCC, KDE, FreeBSD

Git

Distributed Version Control

*nix command line driven design model

advanced features git-stash, git-rebase,git-cherry-pick

Users: Linux kernel, GNOME, Wine, X.org

Page 28: Version Control - University of Toronto

Distributed vs. Centralized

Page 29: Version Control - University of Toronto

Distributed vs. Centralized

Page 30: Version Control - University of Toronto

Distributed vs. Centralized

Page 31: Version Control - University of Toronto

Distributed vs. Centralized

Centralized (svn)

Pros

Single RepositoryAccess ControlsPredictable Revision NumbersGUI’sSimple to understand

Cons

Online to accessTypically SlowerMerges can be painful

Page 32: Version Control - University of Toronto

Distributed vs. Centralized

Distributed (git)

Pros

Simple setup and lightweightDistributedVery FastBranch and merging easierSub collaboration

Cons

Revision numberingCan be complicated conceptuallyNot backed up

Page 33: Version Control - University of Toronto

New Repo: Subversion

Initialize

# svnadmin create /path/svn

Create a Repository

# svn import /path/project \/path/svn/project/trunk -m ’Initial import’

# svn checkout /path/project/

Make Changes

# vi list.txt# svn ci -m "modified list.txt"# svn status

Page 34: Version Control - University of Toronto

New Repo: Git

Initialize# git config --global user.name "SciNet User"# git config --global user.email [email protected]

Create a Repository

# cd ~user/code/# git init# git add .# git commit -m "create a git repo of my code"

Make Changes

# vi list.txt# git commit -a -m "modified list.txt"# git status

Page 35: Version Control - University of Toronto

Existing Repo: Subversion

Checkout a Project

# svn checkout /path/project/

Make Changes

# vi list.txt# svn ci -m "modified list.txt"# svn status

Page 36: Version Control - University of Toronto

Existing Repo: Git

Checkout a Project

# cd ~user/code/# git clone /path/project/# git checkout master

Make Local Changes

# vi list.txt# git commit -a -m "modified list.txt"

Publish Changes

# git pull (fetch & merge)# git push

Page 37: Version Control - University of Toronto

References

Links

Git http://git-scm.com/

Subversion http://subversion.tigris.org/