Michael Tsai 2011/5/5
Reference
http://betterexplained.com/articles/a-vis ual-guide-to-version-control
/
http://
www.ericsink.com/scm/source_control.html
http://betterexplained.com/articles/intro -to-distributed-version-control-illustrat ed/
Version control
Also called “source control”
Other alias
source configuration management
source code management
You have been doing it
Your own version control system:
KalidAzadResumeOct2006.doc
KalidAzadResumeMar2007.doc
instacalc-logo3.png
instacalc-logo4.png
logo-old.png
“Save as”: leave the old version intact.
Single backup file: Document.old.doc
Version number or date: Document_V1.doc
Share folder for other people to access/modify the fil e(s)
But it doesn’t scale
Imagine putting all the related files of a gigantic software project (e.g. WINDOWS 8) in a single shared folder, and have th ousands of developers accessing it.
NO WAY.
What does a version control sys tem do?
Backup and Restore. Files are saved as they ar e edited, and you can jump to any moment in ti me. Need that file as it was on Feb 23, 2007?
No problem.
Synchronization. Lets people share files and s tay up-to-date with the latest version.
Short-term undo. Monkeying with a file and mes sed it up? (That’s just like you, isn’t it?) . Throw away your changes and go back to the
“last known good” version in the database.
What does a version control sys tem do?
Long-term undo. Sometimes we mess up bad. Suppose you made a change a year ago, and it had a bug. Ju mp back to the old version, and see what change wa s made that day.
Track Changes. As files are updated, you can leave messages explaining why the change happened (store d in the VCS, not the file). This makes it easy to see how a file is evolving over time, and why.
Track Ownership. A VCS tags every change with the name of the person who made it. Helpful for blames torming giving credit.
What does a version control sys tem do?
Sandboxing, or insurance against yourself . Making a big change? You can make tempo rary changes in an isolated area, test an d work out the kinks before “checking in
” your changes.
Branching and merging. A larger sandbox.
You can branch a copy of your code into a separate area and modify it in isolation (tracking changes separately). Later, you can merge your work back into the common area.
Learn some terms
Server Client
Working copy Working
copy Repository
(file database) Trunk:
main
line v2_dev el v1_old_stabl
e
v3_new_te st
Main trunk
r3:
milk eggs juice
r4:
milk eggs soup Check out
Working copy:
milk eggs soup
Check in Revert
Main trunk
r1:
milk
r2:
milk eggs
r3:
milk eggs juice
r4:
milk eggs soup
+juice +eggs
-juice, +sou
p
????
Main trunk
r4:
milk eggs soup
New Features
r7:
milk eggs soup bread eggs
soup
eggs rice
Main trunk
r4:
milk eggs soup
New Features
r7:
milk eggs soup bread eggs
soup
eggs rice +rice
+brea d
r8:
milk eggs soup bread
rice +rice
Main trunk
r3:
milk eggs juice
r4:
milk cheese
juice
Working copy (r3*):
milk hot dog
juice Working
copy (r3*):
milk cheese
juice
-eggs +hot
dog e
Valid check-in
Conflicting check-in (cannot remove eggs)
How to resolve the conflict?
Re-apply your changes. Sync to the latest version (r4) and re-apply your changes to this file: Add hot dog to the list that a lready has cheese.
Override their changes with yours. Check out the latest version (r4), copy over yo ur version, and check your version in. In effect, this removes cheese and replaces it with hot dog.
Main trunk
r1:
milk
r2:
milk eggs
r3:
milk eggs juice
r4:
milk eggs soup
1.0 1.5 2.0
Main trunk IE
Window s MP 10
IE 6
Window s MP 10
IE 6
M11 s
MP 11 IE 6
IE7 s
MP 11 IE 7
Window s MP 10
IE 6
IE7
Window s MP 10
IE 7
MP1 1
Window s MP 11
IE 7
Window s MP 11
IE 7
MP RI FI
RI FI
How do I get started?
Try subversion. It’s free!
(not the fastest/fanciest/most powerful on the marke t, but it’s good enough for most projects)
Windows GUI for subversion: TortoiseSVN http://tortoisesvn.tigris.org/
Very easy to use!
Free book about subversion:
http://svnbook.red-bean.com/
We will have a homework for you next week (HW4-2)
Once you know how to use it, make it a habit (not ha rd at all).
Further reading
Distributed Version Control:
http://betterexplained.com/articles/intro -to-distributed-version-control-illustrat ed/
(don’t know if we will cover it this sem ester)