TWiki> Main Web>SVNBasicUsage (2009-02-02, brodbd)EditAttach

Subversion -- Basic Use

(For additional info, see Chapter 2 of the Subversion book and the Subversion Quick Reference Card (PostScript).)

Initial import

Initial import is done with the svn import command. It takes two arguments -- a source directory, and a destination URL. You can also supply a log message with -m. 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:// -m "Initial import of sample Subversion project."
Adding         svn-demo/party
Adding         svn-demo/party/potluck.txt
Adding         svn-demo/party/pizza-toppings.txt

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://
A    trunk/party
A    trunk/party/potluck.txt
A    trunk/party/pizza-toppings.txt
Checked out revision 198.

Basic workflow

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.

$ svn status
?      location.txt
M      potluck.txt

The question mark means there's a new file that Subversion doesn't know about yet. That can be fixed with svn add.

$ svn add location.txt
A         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
Index: 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.

svn commit requires a log message, just like svn import does.

$ svn commit -m "potluck.txt: Add another dish to pass; location.txt: Add new file for party location."
Adding         party/location.txt
Sending        party/potluck.txt
Transmitting file data ..
Committed revision 199.

Note: 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.

-- DavidBrodbeck - 02 Feb 2009

Topic revision: r3 - 2009-02-02 - 19:57:46 - brodbd

This site is powered by the TWiki collaboration platformCopyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Privacy Statement Terms & Conditions