Вы находитесь на странице: 1из 22

Introduction to SVN

Elliott Hoffman
June 12, 2009
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0
What is SVN?
Version control software
Used by many software developers
Free: works on Windows, Linux and Mac
Open source (Apache License)
Use
Information stored in a central location
People can check in/out copies of
information
Revision history is maintained
Can version any type of file
Users decide how to organize their files
SVN for the developer
Keep a record of all your code changes
without having to maintain backup files
Freeze and thaw the state of your code at
any time
Version any non-code files you want
SVN for the team
New branches of code can be created at
will to facilitate simultaneous development
Used in tandem with diff/merge tools
Using SVN – The Repository
Calc & Paint are projects
Each project has a trunk and
branches
Trunk is the “main line” of
development
Branches are offshoots to store
changes so that they do not
affect the trunk’s files
Using SVN - Trunk
Generally contains stable code
Branches are often created from and
merged back into the trunk
The 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 branch
Branch to make a large code change
without interrupting other development
Branch 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 Explorer
Right-click access to most SVN commands
Easy to use
Many other ways to connect SVN with
your development tools!
Terminology - Nouns
Repository
Central storage for your files, change history
and comments.
Revision
A snapshot of a set of files.
Working Copy
A copy of a revision , saved locally to edit.
Terminology - Verbs
Check Out
Save a working copy to your pc.
Update
Automatically merge changes others have
made into your working copy .
Commit
Save your working copy ’s changes back into
the repository .
Terminology - Verbs
Merge
Move copy changes from one branch to
another (more on this later)
Basic SVN work cycle
1. Check out a working copy
2. Make changes
3. Examine your changes
4. Update your working copy
5. Commit your changes
Pitfalls
Once a file is under version control, only
rename, move or delete it via SVN
commands
SVN is case sensitive
How SVN manages data
SVN makes “cheap copies” of data
Only the changes between versions are
stored in the repository
SVN updates overlay the working copy.
They do not replace the local copy
Conflicts
Occur when changes from the repository
overlap with your own changes
SVN 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 resolved
SVN will
delete the three temp files if they exist
allow 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”
Resources
Free SVN e-book from O’Reilly
(Creative Commons Attribution 2.0 Generic license)
http://svnbook.red-bean.com/

SVN entry on Wikipedia


http://en.wikipedia.org/wiki/Subversion_(software)
End

Questions?

Вам также может понравиться