You are on page 1of 22
Version Control By Nathan Bertram 7th / August / 2008

Version Control

By Nathan Bertram 7th / August / 2008

Intro.

Who am I? And what do I do?

Intro.

What is Version Control?

- Version Control lets you track your files over time in a logical manner. Keep a log of who, when and why changes occurred. - Often refereed to as Revision Control or Source Control.

Intro.

You use it every day. And you don’t even know it.

myfile_v4.as
myfile_v4.as
myfile_v4.as
myfile_v4.as
myfile_v4.as

myfile_v4.as

myfile_jun08.fla
myfile_jun08.fla
myfile_jun08.fla
myfile_jun08.fla
myfile_jun08.fla

myfile_jun08.fla

myfile_test02.fla
myfile_test02.fla
myfile_test02.fla
myfile_test02.fla
myfile_test02.fla

myfile_test02.fla

myfile_final.swf
myfile_final.swf
myfile_final.swf
myfile_final.swf
myfile_final.swf

myfile_final.swf

Basic Terminology

Repository (repo) - The database for storing all your files.

Server - Where your repository is stored.

Client - The computer connecting to the repo.

Working Copy / Working Set - Your local directory of files, where you make changes.

Main Trunk - The “primary” location for code in the repo.

Revision - What version a file is on (rev1, rev2, rev3 & etc.).

Head - The latest revision in the repo.

Repository
Repository
Client A
Client
A
Repository
Repository
Repository Client C Client A Client B
Client C
Client
C
Client A
Client
A
Repository Client C Client A Client B
Client B
Client
B
Client D
Client
D
Client E
Client
E
Client F
Client
F
Client D Client E Client F Repository Client C Client A Client B
Client D Client E Client F Repository Client C Client A Client B
Repository
Repository
Client D Client E Client F Repository Client C Client A Client B
Client D Client E Client F Repository Client C Client A Client B
Client C
Client
C
Client A
Client
A
Client D Client E Client F Repository Client C Client A Client B
Client B
Client
B
Client D
Client
D
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client E
Client
E
Client F
Client
F
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client
Client
Client G
Client
G
I
I
Repository
Repository
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client A
Client
A
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client B
Client
B
Client D Client E Client F Client Client G I Repository Client A Client B Client
Client J
Client
J
Client H
Client
H
Client C
Client
C

More Basic Terminology

Add - Put a file into the repo for the first time (begin tracking it with Version Control).

Check Out - Download a file from the repo.

Check In / Commit - Upload a file to the repository (if it has changed). The file gets a new revision number, and team members can “check out” the latest one.

Update / Sync - Synchronize your files with the latest from the repository. This lets you grab the latest revisions of all files.

Checkin Message - A short message describing what was changed.

Changelog / History - A list of changes made to a file since it was created

Revert - Throw away your local changes and reload the latest version from the repository.

Status - What files with in your working directory have been modified.

Basic Checkins

Main Trunk ice cream hp sauce
Main Trunk
ice cream
hp sauce

Rev. 1

Joe creates list.txt with two lines of text and adds it to the repository he has just set up.

Basic Checkins

Main Trunk ice cream ice cream hp sauce bread milk Rev. 1 eggs
Main Trunk
ice cream
ice cream
hp sauce
bread
milk
Rev. 1
eggs

Rev. 2

Jeff checks out list.txt and edits the file and removes the line “hp sauce” from the file and adds in “bread”,“milk” and “eggs”. Jeff then checks in the list.txt.

Basic Checkins

Main Trunk ice cream ice cream ice cream ice cream hp sauce bread bread bread
Main Trunk
ice cream
ice cream
ice cream
ice cream
hp sauce
bread
bread
bread
milk
milk
milk
Rev. 1
eggs
eggs
eggs
cake
Rev. 2
Rev. 4

Rev. 3

Each time we check in a new copy a new revision number is set for the file.

A Closer Look

Main Trunk ice cream Check Out ice cream hp sauce bread milk Rev. 1 eggs
Main Trunk
ice cream
Check Out
ice cream
hp sauce
bread
milk
Rev. 1
eggs
Rev. 2
ice cream
Revert
bread
Check In
milk
eggs

Working Copy

Intermediate / Advanced Terminology

Diff / Change / Delta - Finding variance between two files.

Branch - Create a separate copy of a file/folder for private use (debugging, experimenting & etc).

Merge / Patch - Apply changes from one file to another, to bring it up to date.

Conflict - When pending changes to a file contradict each other (both changes cannot be applied).

Resolve - Fixing the files that contradict each other and checking in the fixed correct

Locking - “Taking Control” over a file. So that only the owner of the file can edit the file until the owner has unlocked the file. Used to avoid conflicts in critical phase of file.

Breaking the Lock - Forcibly unlocking a file so that you can edit it. It may be needed if someone on the team is away.

Tagging - Define your own version number in addition to the revision numbering. Eg. v1.01, 1.02, 1.03 or v1.0, v1.5, v2.0

Basic Diffs

Main Trunk ice cream + bread ice cream ice cream + cake hp sauce +
Main Trunk
ice cream
+ bread
ice cream
ice cream
+ cake
hp sauce
+ milk
bread
bread
+ eggs
milk
milk
Rev. 1
- hp sauce
eggs
eggs
cake
Rev. 2

Rev. 3

Diff / Change / Delta - Finding variance between two files. Many VCS store Diffs rather than entire copies of the file to save space over multiple versions.

Branching

ice cream

hp sauce

ice cream

ice cream

soup

soup

rice

peanuts

Rev. 2

Rev. 3 Rev. 5 Branch
Rev. 3
Rev. 5
Branch
soup rice peanuts Rev. 2 Rev. 3 Rev. 5 Branch Main Trunk ice cream hp sauce
Main Trunk
Main Trunk

ice cream

hp sauce

Rev. 1

ice cream

bread

milk

eggs

Rev. 4

ice cream

bread

milk

eggs

cake

ice cream

bread

milk

eggs

Rev. 7

Rev. 6

Branching allows us to make a copy of our files in a folder and work with them separately from the Main Trunk.

Merging

Milk

Eggs

Bread

Cake

Milk

+ Cake

Eggs

 

Bread

Eggs Bread Cake Milk + Cake Eggs   Bread Rev. 2 Rev. 3 Branch Main Trunk
Eggs Bread Cake Milk + Cake Eggs   Bread Rev. 2 Rev. 3 Branch Main Trunk
Rev. 2 Rev. 3 Branch Main Trunk Milk Milk Milk Eggs + Sugar Eggs +
Rev. 2
Rev. 3
Branch
Main Trunk
Milk
Milk
Milk
Eggs
+ Sugar
Eggs
+ Cake
Eggs
Bread
Bread
Bread
Sugar
Rev. 1
Sugar
Rev. 4
Cake

Rev. 5

Merging allows you to apply changes from one file to another.

Conflicts!

ice cream + bread ice cream Joe: hp sauce - hp sauce bread Rev. 1
ice cream
+ bread
ice cream
Joe:
hp sauce
- hp sauce
bread
Rev. 1
Conflict
Main Trunk
ice cream
+ eggs
ice cream
Jane:
hp sauce
- hp sauce
eggs
Rev. 1
Rev. 2

Conflicts arise when pending changes to a file contract each other. Both changes cannot be applied. Joe and Jane both check out the file at the same time. Jane is the first check in her changes. Joe goes to check in his version of the file later in the day. However, a conflict arrises because in the latest revision in the repository there is no hp sauce to remove!

Resolving Conflicts!

Joe:

ice cream

hp sauce

+ bread

Resolving Conflicts ! Joe: ice cream hp sauce + bread - hp sauce ice cream bread

- hp sauce

ice cream

bread

Rev. 1 Conflict Main Trunk ice cream + eggs ice cream Jane: hp sauce -
Rev. 1
Conflict
Main Trunk
ice cream
+ eggs
ice cream
Jane:
hp sauce
- hp sauce
bread
milk
Rev. 1
eggs

Rev. 2

When conflicts arise it is up to you to check in a newer version that resolves the conflict. One approach is to sync to the current version of the file and reapply your changes to it.

Key Points.

- Easily keep track of who, when and why changes occurred.

- Your project files are always backed up on a remote server in a repository.

- Easily collaborate on the same code base at any given time.

- Jump back in time an access previous revisions.

- Branch out and develop other features while the main project goes on.

- Take it slow and keep on learning.