Introduction to SVN Elliott Hoffman June 12, 2009 Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0

Introduction to SVN

Embed Size (px)


A brief, high-level explanation of the Subversion version control system. This pdf was originally presented to train a small group of software engineers and architects. Topics include: What is svn, the basic terms and workflows, and a few details on how svn works internally. Also includes links to obtain SVN, the TortoiseSVN client for Windows, and the O'Reilly svn redbook.

Citation preview

Page 1: Introduction to SVN

Introduction to SVN

Elliott HoffmanJune 12, 2009

Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0

Page 2: Introduction to SVN

What is SVN?

Version control softwareUsed by many software developersFree: works on Windows, Linux and MacOpen source (Apache License)

Page 3: Introduction to SVN


Information stored in a central locationPeople can check in/out copies of informationRevision history is maintainedCan version any type of fileUsers decide how to organize their files

Page 4: Introduction to SVN

SVN for the developer

Keep a record of all your code changes without having to maintain backup filesFreeze and thaw the state of your code at any timeVersion any non-code files you want

Page 5: Introduction to SVN

SVN for the team

New branches of code can be created at will to facilitate simultaneous developmentUsed in tandem with diff/merge tools

Page 6: Introduction to SVN

Using SVN – The RepositoryCalc & Paint are projectsEach project has a trunk and branchesTrunk is the “main line” of developmentBranches are offshoots to store changes so that they do not affect the trunk’s files

Page 7: Introduction to SVN

Using SVN - Trunk

Generally contains stable codeBranches are often created from and merged back into the trunkThe trunk is just another branch to SVN: it’s just an organizational convention

Page 8: Introduction to SVN

Using SVN - Branches

Branches are off-shoots from the trunk or another branchBranch to make a large code change without interrupting other developmentBranch to keep code versions separate (e.g. 1.0 vs. 3.0 versions of the same project)Merge branches into other branches later

Page 9: Introduction to SVN

Using SVN - Branches

Visualization of a very simple Subversion project Source: http://en.wikipedia.org/wiki/Image:Subversion_project_visualization.svg

Page 10: Introduction to SVN

Getting SVN

SVN http://subversion.tigris.org/TortoiseSVN – a Windows GUI SVN client http://tortoisesvn.net/downloads

Integrated w/ Windows ExplorerRight-click access to most SVN commandsEasy to use

Many other ways to connect SVN with your development tools!

Page 11: Introduction to SVN

Terminology - Nouns

RepositoryCentral storage for your files, change history and comments. RevisionA snapshot of a set of files.Working CopyA copy of a revision , saved locally to edit.

Page 12: Introduction to SVN

Terminology - Verbs

Check OutSave a working copy to your pc.UpdateAutomatically merge changes others have made into your working copy .CommitSave your working copy ’s changes back into the repository .

Page 13: Introduction to SVN

Terminology - Verbs

MergeMove copy changes from one branch to another (more on this later)

Page 14: Introduction to SVN

Basic SVN work cycle

1. Check out a working copy2. Make changes3. Examine your changes4. Update your working copy5. Commit your changes

Page 15: Introduction to SVN


Once a file is under version control, only rename, move or delete it via SVN commandsSVN is case sensitive

Page 16: Introduction to SVN

How SVN manages data

SVN makes “cheap copies” of dataOnly the changes between versions are stored in the repositorySVN updates overlay the working copy. They do not replace the local copy

Page 17: Introduction to SVN

ConflictsOccur when changes from the repository overlap with your own changesSVN cancels the update and creates 3 temp files:

Filename.mine (Your local file as is)Filename.rOldRev (The version before you made your changes)Filename.rNewRev (The version with the server’s changes)

SNV also annotates your original file to tell you where the conflicts are

Page 18: Introduction to SVN

Conflict Resolution

SVN won’t update while those three temp files exist. You have three options:1. Merge the conflicted text “by hand” (by

examining and editing the conflict file).2. Copy one of the temporary files on top of your

local file.3. Run the revert command to throw away all of

your local changes.

Page 19: Introduction to SVN

Conflict Resolution

After you take action, tell SVN that the files are resolvedSVN will

delete the three temp files if they existallow the update again

Conflicts are rare if users update and check in frequently!

Page 20: Introduction to SVN

How Merging Works

In other words:“Apply the delta between two revisions to a target revision .”

Example:revision1 = “a b c d e”revision2 = “b c d f”D = Δ(revision1, revision2) = “-a … -e … + f”Merge(D, “a z y x”) = “z y x f”

Page 21: Introduction to SVN

ResourcesFree SVN e-book from O’Reilly

(Creative Commons Attribution 2.0 Generic license)http://svnbook.red-bean.com/

SVN entry on Wikipediahttp://en.wikipedia.org/wiki/Subversion_(software)

Page 22: Introduction to SVN