Subversion -- Basic Use
(For additional info, see Chapter 2 of the Subversion book
and the Subversion Quick Reference Card (PostScript)
Initial import is done with the
command. It takes two arguments -- a source directory, and a destination URL. You can also supply a log message with
. The message is mandatory -- if you don't provide one, your default editor will be started so you can compose one.
$ svn import svn-demo svn://lemur.ling.washington.edu/test/svn-demo/trunk -m "Initial import of sample Subversion project."
Committed revision 198.
Checking out a working copy
Importing a directory does not automatically make it a working copy under version control. To do that, it's necessary to check it out, just like you would with someone else's project.
$ svn checkout svn://lemur.ling.washington.edu/test/svn-demo/trunk
Checked out revision 198.
Once you've got a project under version control, day-to-day use follows a simple pattern.
1. Make sure you're up to date.
This can be skipped if you're working on your own private project. If you're collaborating with others, however, it's best to make sure you have the most recent revision before you start editing files.
$ svn update
At revision 198.
2. Make your changes.
Edit files as you normally would.
3. View the status of your files, and fix any problems.
To see what changes you've made, you can use
$ svn status
The question mark means there's a new file that Subversion doesn't know about yet. That can be fixed with
$ svn add location.txt
If you're working on textual files (such as text or source code) you can also view the specific changes to a particular file.
$ svn diff potluck.txt
--- potluck.txt (revision 198)
+++ potluck.txt (working copy)
@@ -3,3 +3,4 @@
Alice - Salad
Earl - Scalloped potatoes
Sue - Jell-O
+David - Chocolate cherry cake
4. Commit the changes.
requires a log message, just like
$ svn commit -m "potluck.txt: Add another dish to pass; location.txt: Add new file for party location."
Transmitting file data ..
Committed revision 199.
Revision numbers will not always be consecutive. They're global for the entire repository, so commits to other projects will increment the version number you see.
- 02 Feb 2009