Upload
elliotthoffman
View
138
Download
0
Tags:
Embed Size (px)
DESCRIPTION
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
Introduction to SVN
Elliott HoffmanJune 12, 2009
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0
What is SVN?
Version control softwareUsed by many software developersFree: works on Windows, Linux and MacOpen source (Apache License)
Use
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
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
SVN for the team
New branches of code can be created at will to facilitate simultaneous developmentUsed in tandem with diff/merge tools
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
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
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
Using SVN - Branches
Visualization of a very simple Subversion project Source: http://en.wikipedia.org/wiki/Image:Subversion_project_visualization.svg
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!
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.
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 .
Terminology - Verbs
MergeMove copy changes from one branch to another (more on this later)
Basic SVN work cycle
1. Check out a working copy2. Make changes3. Examine your changes4. Update your working copy5. Commit your changes
Pitfalls
Once a file is under version control, only rename, move or delete it via SVN commandsSVN is case sensitive
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
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
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.
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!
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”
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)
End
Questions?